From 7d5f67e3842a9b04087196a17d638d0a976f8a0a Mon Sep 17 00:00:00 2001 From: camperbot Date: Mon, 24 Oct 2022 18:55:50 +0100 Subject: [PATCH] chore(i18n,learn): processed translations (#48235) --- .../build-a-survey-form.md | 2 +- ...to-assign-variables-from-nested-objects.md | 4 +- .../problem-128-hexagonal-tile-differences.md | 63 ++++++++------ .../problem-47-distinct-primes-factors.md | 33 +++---- .../problem-50-consecutive-prime-sum.md | 86 +++++++++++-------- .../problem-51-prime-digit-replacements.md | 56 +++++++----- .../build-a-survey-form.md | 2 +- .../61537c9eecea6a335db6da79.md | 2 +- .../5d822fd413a79914d39e98d5.md | 2 +- .../5d822fd413a79914d39e98de.md | 4 +- .../5ef9b03c81a63668521804dc.md | 19 +++- .../62aa226207f33d3ad4c6f546.md | 6 +- .../build-a-survey-form.md | 2 +- ...to-assign-variables-from-nested-objects.md | 4 +- .../find-the-symmetric-difference.md | 2 +- .../algorithms/implement-binary-search.md | 38 ++++---- .../problem-128-hexagonal-tile-differences.md | 63 ++++++++------ .../problem-47-distinct-primes-factors.md | 33 +++---- .../problem-50-consecutive-prime-sum.md | 86 +++++++++++-------- .../problem-51-prime-digit-replacements.md | 56 +++++++----- .../build-a-survey-form.md | 2 +- .../6147a14ef5668b5881ef2297.md | 4 +- .../61537c9eecea6a335db6da79.md | 2 +- .../5d822fd413a79914d39e98de.md | 4 +- .../5ef9b03c81a63668521804dc.md | 19 +++- .../62aa226207f33d3ad4c6f546.md | 6 +- .../build-a-survey-form.md | 2 +- ...to-assign-variables-from-nested-objects.md | 4 +- .../find-the-symmetric-difference.md | 2 +- .../algorithms/implement-binary-search.md | 38 ++++---- .../problem-128-hexagonal-tile-differences.md | 63 ++++++++------ .../problem-47-distinct-primes-factors.md | 33 +++---- .../problem-50-consecutive-prime-sum.md | 86 +++++++++++-------- .../problem-51-prime-digit-replacements.md | 56 +++++++----- .../build-a-survey-form.md | 2 +- .../6147a14ef5668b5881ef2297.md | 4 +- .../61537c9eecea6a335db6da79.md | 2 +- .../5d822fd413a79914d39e98de.md | 4 +- .../5ef9b03c81a63668521804dc.md | 19 +++- .../62aa226207f33d3ad4c6f546.md | 6 +- .../build-a-survey-form.md | 2 +- ...to-assign-variables-from-nested-objects.md | 4 +- .../problem-128-hexagonal-tile-differences.md | 63 ++++++++------ .../problem-47-distinct-primes-factors.md | 33 +++---- .../problem-50-consecutive-prime-sum.md | 86 +++++++++++-------- .../problem-51-prime-digit-replacements.md | 56 +++++++----- .../build-a-survey-form.md | 2 +- .../5d822fd413a79914d39e98de.md | 4 +- .../5ef9b03c81a63668521804dc.md | 19 +++- .../62aa226207f33d3ad4c6f546.md | 6 +- .../build-a-survey-form.md | 2 +- ...to-assign-variables-from-nested-objects.md | 4 +- .../problem-128-hexagonal-tile-differences.md | 63 ++++++++------ .../problem-47-distinct-primes-factors.md | 33 +++---- .../problem-50-consecutive-prime-sum.md | 86 +++++++++++-------- .../problem-51-prime-digit-replacements.md | 56 +++++++----- .../build-a-survey-form.md | 2 +- .../5d822fd413a79914d39e98de.md | 4 +- .../5ef9b03c81a63668521804dc.md | 11 +++ .../62aa226207f33d3ad4c6f546.md | 6 +- .../build-a-survey-form.md | 2 +- ...to-assign-variables-from-nested-objects.md | 4 +- .../problem-125-palindromic-sums.md | 8 +- .../problem-128-hexagonal-tile-differences.md | 63 ++++++++------ .../problem-47-distinct-primes-factors.md | 33 +++---- .../problem-50-consecutive-prime-sum.md | 86 +++++++++++-------- .../problem-51-prime-digit-replacements.md | 56 +++++++----- .../rosetta-code/state-name-puzzle.md | 2 +- .../build-a-survey-form.md | 2 +- .../5d822fd413a79914d39e98de.md | 4 +- .../5ef9b03c81a63668521804dc.md | 19 +++- .../62aa226207f33d3ad4c6f546.md | 6 +- .../build-a-survey-form.md | 2 +- ...to-assign-variables-from-nested-objects.md | 4 +- .../problem-128-hexagonal-tile-differences.md | 63 ++++++++------ .../problem-47-distinct-primes-factors.md | 33 +++---- .../problem-50-consecutive-prime-sum.md | 86 +++++++++++-------- .../problem-51-prime-digit-replacements.md | 56 +++++++----- .../build-a-survey-form.md | 12 +-- .../6148da157cc0bd0d06df5c0a.md | 6 +- .../61437d575fb98f57fa8f7f36.md | 34 ++++---- .../5d822fd413a79914d39e98d5.md | 2 +- .../5d822fd413a79914d39e98de.md | 4 +- .../5d822fd413a79914d39e98ef.md | 2 +- .../5d822fd413a79914d39e98fa.md | 2 +- .../5d822fd413a79914d39e9903.md | 2 +- .../5d822fd413a79914d39e990c.md | 2 +- .../5d822fd413a79914d39e9915.md | 4 +- .../5d822fd413a79914d39e9929.md | 8 +- .../5d822fd413a79914d39e992a.md | 6 +- .../5d822fd413a79914d39e992b.md | 6 +- .../5d822fd413a79914d39e992c.md | 6 +- .../5d822fd413a79914d39e992d.md | 8 +- .../5d822fd413a79914d39e992e.md | 6 +- .../5d822fd413a79914d39e992f.md | 6 +- .../5d822fd413a79914d39e9930.md | 6 +- .../5d822fd413a79914d39e9931.md | 4 +- .../5d822fd413a79914d39e9932.md | 10 +-- .../5d822fd413a79914d39e9933.md | 10 +-- .../5d822fd413a79914d39e9934.md | 10 +-- .../5d822fd413a79914d39e9935.md | 8 +- .../5d822fd413a79914d39e9936.md | 4 +- .../5d822fd413a79914d39e9937.md | 4 +- .../5d822fd413a79914d39e9938.md | 10 +-- .../5d822fd413a79914d39e9939.md | 4 +- .../5d822fd413a79914d39e993a.md | 6 +- .../5d822fd413a79914d39e993b.md | 8 +- .../5d822fd413a79914d39e993c.md | 8 +- .../5d822fd413a79914d39e993d.md | 12 +-- .../5d822fd413a79914d39e993e.md | 12 +-- .../5ef9b03c81a63668521804dc.md | 19 +++- .../62aa226207f33d3ad4c6f546.md | 6 +- .../build-a-survey-form.md | 2 +- ...to-assign-variables-from-nested-objects.md | 4 +- .../problem-128-hexagonal-tile-differences.md | 63 ++++++++------ .../problem-47-distinct-primes-factors.md | 33 +++---- .../problem-50-consecutive-prime-sum.md | 86 +++++++++++-------- .../problem-51-prime-digit-replacements.md | 56 +++++++----- .../build-a-survey-form.md | 2 +- .../5d822fd413a79914d39e98de.md | 4 +- .../5ef9b03c81a63668521804dc.md | 19 +++- .../62a115879a6d51422652cbfc.md | 18 ++-- .../62a1166ed9a56d439c0770e7.md | 14 +-- .../62a23c1d505bfa13747c8a9b.md | 34 ++++---- .../62a23cb9bc467a147516b500.md | 18 ++-- .../62a2401b9842721796b72850.md | 6 +- .../62a24068d60b671847d1d4e2.md | 8 +- .../62a2409897ec621942234cf6.md | 12 +-- .../62a240c67f3dbb1a1e6d95ee.md | 18 ++-- .../62a24128d5e8af1b47ad1aab.md | 12 +-- .../62a241df03c1f61ce936f5d9.md | 8 +- .../62a2509ba163e020bb9d84ea.md | 10 +-- .../62a255dae245b52317da824a.md | 12 +-- .../62a257659d0d1e2456f24ba2.md | 8 +- .../62a39f5a5790eb27c1e5d4bf.md | 8 +- .../62a3a0a3c0a4b32915d26a6e.md | 18 ++-- .../62a3a488b24fb32b91155d56.md | 10 +-- .../62a3a75d8466a12e009eff76.md | 18 ++-- .../62a3a7e4f1060e2fc5ffb34b.md | 14 +-- .../62a3b365f1cdeb33efc2502e.md | 8 +- .../62a3b3eab50e193608c19fc6.md | 10 +-- .../62a3b41c9494f937560640ab.md | 18 ++-- .../62a3b49686792938718b90d3.md | 10 +-- .../62a3b506dbaead396f58a701.md | 18 ++-- .../62a3b5843544ce3a77459c27.md | 10 +-- .../62a3b79d520a7f3d0e25afd6.md | 14 +-- .../62a3bb9aeefe4b3fc43c6d7b.md | 10 +-- .../62a3bec30ea7f941412512dc.md | 32 +++---- .../62a3c0ab883fd9435cd5c518.md | 10 +-- .../62a3c2fccf186146b59c6e96.md | 12 +-- .../62a3c4a0e52767482c5202d4.md | 16 ++-- .../62a3c668afc43b4a134cca81.md | 14 +-- .../62a3c8bf3980c14c438d2aed.md | 8 +- .../62a3c91a2bab1b4d6fabb726.md | 12 +-- .../62a3cdb11478a34ff4a6470d.md | 14 +-- .../62a3cfc8328d3351b95d4f61.md | 18 ++-- .../62a7beb1ad61211ac153707f.md | 20 ++--- .../62a7bf06d2ad9d1c5024e833.md | 28 +++--- .../62a7bfabe119461eb13ccbd6.md | 12 +-- .../62a7bfd9179b7f1f6a15fb1e.md | 16 ++-- .../62a7c011eef9fb2084b966db.md | 8 +- .../62a7c071219da921758a35bb.md | 18 ++-- .../62a7cc99577fbf25ee7a7d76.md | 12 +-- .../62a8a929e4260d08093756d2.md | 10 +-- .../62a8a9d876b2580943ba9351.md | 10 +-- .../62a8aa98a8289d0a698eee1d.md | 12 +-- .../62a8ab0e27cbaf0b54ba8a42.md | 16 ++-- .../62a8ac194679e60cb561b0a8.md | 14 +-- .../62a8ad8e01d7cb0deae5ec66.md | 16 ++-- .../62a8ade9b2f5b30ef0b606c2.md | 10 +-- .../62a8ae85fcaedc0fddc7ca4f.md | 24 +++--- .../62a8b0b5053f16111b0b6b5f.md | 22 ++--- .../62a8b1762b7775124622e1a3.md | 8 +- .../62a8b3cc436db8139cc5fc09.md | 6 +- .../62a8b6536156c51500739b41.md | 14 +-- .../62a8b711ab7a12161c7d9b67.md | 8 +- .../62a8b9770050d217d2247801.md | 8 +- .../62a8c0c8313e891a15ec23e7.md | 12 +-- .../62a8c1154d3ae11aee80353f.md | 16 ++-- .../62a8c151b23bf21bc7c4fcba.md | 8 +- .../62a8c173949f851c83c64756.md | 10 +-- .../62a8c242b25a531f2909e5bc.md | 12 +-- .../62a8c2bbbd8aa82052f47c53.md | 24 +++--- .../62a8c31ec0ec78216a1c36a0.md | 14 +-- .../62a8c370ad8c68227137e0bc.md | 10 +-- .../62a8c3ebc6c35e23785e1a19.md | 8 +- .../62a8c41ecaf1bd24536129b8.md | 12 +-- .../62a8c465fa7b0c252f4a8f0c.md | 12 +-- .../62a8c4db0710f3260f867a92.md | 12 +-- .../62a8c56247609626fa4a8d6e.md | 12 +-- .../62a8c5db7888af27af23f0dd.md | 10 +-- .../62a8c65b75664c28a8e59c16.md | 8 +- .../62a8c6815f5f1a29735efe1b.md | 10 +-- .../62a8c7322e42962ad53ad204.md | 16 ++-- .../62a8c7a59e72c02bb1c717d2.md | 8 +- .../62a8c89e4272512d44fc1c66.md | 10 +-- .../62a8ca22d29fe62f3952bdf5.md | 10 +-- .../62a8cb19bd7f8a304e5427a1.md | 8 +- .../62a8cbd1e3595431d5a2b3f1.md | 12 +-- .../62a8cce1b0c32c33017cf2e9.md | 10 +-- .../62a8ce1dfc990134162b3bd9.md | 6 +- .../62a8ce73d0dce43468f6689c.md | 12 +-- .../62a8cf22272d6d35af80d4ac.md | 14 +-- .../62a8d0337d7c67377a4a76c6.md | 10 +-- .../62a8d08668fa8b38732486e9.md | 8 +- .../62a8d0c4f12c2239b6618582.md | 12 +-- .../62a8d0fdf2dad83a92883a80.md | 10 +-- .../62a8d143f2a58e3b6d6e9c33.md | 8 +- .../62a8d1c72e8bb13c2074d93c.md | 8 +- .../62a8d2146a3e853d0a6e28ca.md | 10 +-- .../62a8d24c97461b3ddb9397c8.md | 12 +-- .../62a8d2e2a073be3edb46116f.md | 8 +- .../62a8d31ebbc10e3fe1b28e03.md | 8 +- .../62a8d35660db4040ba292193.md | 10 +-- .../62a8d382cd075f4169223e14.md | 8 +- .../62a8d539dc11cb42b5dd7ec8.md | 10 +-- .../62a8d61ddfe35744369365b7.md | 14 +-- .../62a8d6c7001ebc45350e3d16.md | 12 +-- .../62a8d7b8ab568b4649998954.md | 10 +-- .../62a8d81f539f004776dd9b1e.md | 34 ++++---- .../62a8dd468debb449b4454086.md | 8 +- .../62a8dd9cdb16324b04cfd958.md | 12 +-- .../62a8e0d1d0110b4ec421489f.md | 12 +-- .../62a8e142f7f0bd4fed898de3.md | 16 ++-- .../62a8e1dc897df55108bcb5e8.md | 8 +- .../62a8e21398ad61520edb724f.md | 8 +- .../62a8e24c673b075317cc0b09.md | 10 +-- .../62a8e271f8e3d1541f9624ad.md | 12 +-- .../62a8e35675c18c56354c08cf.md | 12 +-- .../62a8e41e2f190c58404dd46e.md | 14 +-- .../62a8e45cc600c3591cee671a.md | 8 +- .../62a8e4dc6a60f85bf256a0cb.md | 24 +++--- .../62a8ed36d7a7915dfa444ba2.md | 12 +-- .../62a8edd05e27cc668051686f.md | 10 +-- .../62a8ee154c8946678775c4a4.md | 12 +-- .../62a8ee71f018e968a056d369.md | 12 +-- .../62a8eec45f77bc69e8775294.md | 8 +- .../62a8eefe2e68b66ac563816b.md | 12 +-- .../62a8ef6a52292f6bdca4f6f8.md | 8 +- .../62a8ef8f0c76a46cd221a68c.md | 8 +- .../62a8efb0e3ce826db8daf80f.md | 8 +- .../62a8eff21c0b0f6ebe5b8e38.md | 16 ++-- .../62a8f06fb318666fef69f91e.md | 8 +- .../62a8f14fe6d1fc72454648c7.md | 10 +-- .../62a8f1d5f5ddbf74c07f733b.md | 6 +- .../62a8f20463b324759953edad.md | 28 +++--- .../62a8f256b813a476cae51f49.md | 16 ++-- .../62a8f2bc37675e77d5835235.md | 16 ++-- .../62a8f35bde1750791f58773f.md | 8 +- .../62a94114ce0b8918b487390f.md | 16 ++-- .../62aa1cea594f152ba626b872.md | 8 +- .../62aa1d6736ba262cfa74344b.md | 8 +- .../62aa1d9f535e102e4663e7a6.md | 12 +-- .../62aa1e3c7c3d552fb04f0f18.md | 6 +- .../62aa1e8ccd579330e097ce44.md | 10 +-- .../62aa1eec891ed731db227a36.md | 14 +-- .../62aa1fed3d4e873366ff3131.md | 4 +- .../62aa204c1e1d33348ff09944.md | 6 +- .../62aa20e9cf1be9358f5aceae.md | 8 +- .../62aa2136fc49b836dfedb959.md | 8 +- .../62aa21971e3b743844849985.md | 14 +-- .../62aa21ea8d9d9f396b95dd87.md | 8 +- .../62aa226207f33d3ad4c6f546.md | 14 +-- .../62aa22aba186563bcbf2c395.md | 10 +-- .../62aa234322d4ad3e8bce42cc.md | 14 +-- .../62aa2469c77b363fdb4f0e06.md | 12 +-- .../62aa252c3b1073415ba2b898.md | 8 +- .../62aa258da314ef42ba0a1858.md | 18 ++-- .../62aa25fcb5837d43b4d9873d.md | 16 ++-- .../62aa2626c3c10244b94c787b.md | 6 +- .../62aa264d23cdaa45a20efada.md | 12 +-- .../62aa26cca3cd3d46c431e73b.md | 10 +-- .../62aa27227399d647e1c37a3c.md | 10 +-- .../62aa27560def7048d7b4a095.md | 6 +- .../62aa27c40ca6f04ab8be5fac.md | 6 +- .../62aa28032d863d4bd8058799.md | 10 +-- .../62aa287434dc284cea01157c.md | 8 +- .../62aa28bbd6323e4dfb3ac43e.md | 8 +- .../62aa28fb651bf14efa2dbb16.md | 12 +-- .../62aa2943669c9d5026af6985.md | 12 +-- .../62aa2999ec27ec516655eba6.md | 10 +-- .../62aa29d8f8f88152c91350ca.md | 12 +-- .../62aa2aec2f09d454253aad6c.md | 10 +-- .../62aa2ba9cd881355a6f0a5a8.md | 8 +- .../62b46e3a8d4be31be5af793d.md | 10 +-- .../62ba17beef16c563069a65d8.md | 16 ++-- .../62fc1ee0c5a89717d4785729.md | 14 +-- .../62fc20387ef88d1d1998aac5.md | 12 +-- .../62fc211760bfc220f4734800.md | 8 +- .../build-a-survey-form.md | 2 +- .../escape-sequences-in-strings.md | 2 +- ...to-assign-variables-from-nested-objects.md | 4 +- .../problem-128-hexagonal-tile-differences.md | 63 ++++++++------ .../problem-47-distinct-primes-factors.md | 33 +++---- .../problem-50-consecutive-prime-sum.md | 86 +++++++++++-------- .../problem-51-prime-digit-replacements.md | 56 +++++++----- .../build-a-survey-form.md | 2 +- .../61537c9eecea6a335db6da79.md | 2 +- .../5d822fd413a79914d39e98de.md | 4 +- .../5ef9b03c81a63668521804dc.md | 19 +++- .../62aa226207f33d3ad4c6f546.md | 6 +- 301 files changed, 2645 insertions(+), 2168 deletions(-) diff --git a/curriculum/challenges/arabic/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md b/curriculum/challenges/arabic/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md index 247fb17e35b..8a1b20bb375 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md @@ -119,7 +119,7 @@ const el = document.getElementById('email') assert(!!el && el.required) ``` -Your `#email` should be a descendant of `#survey-form` +Your `#email` should be a descendant of `#survey-form`. ```js const el = document.querySelector('#survey-form #email') diff --git a/curriculum/challenges/arabic/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md b/curriculum/challenges/arabic/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md index b1a3078336b..084e7c9f464 100644 --- a/curriculum/challenges/arabic/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md +++ b/curriculum/challenges/arabic/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md @@ -53,7 +53,7 @@ assert( ```js assert( code.match( - /(var|const|let)\s*{\s*today\s*:\s*{\s*(low\s*:\s*lowToday[^}]*|[^,]*,\s*low\s*:\s*lowToday\s*)}\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g + /(var|const|let)\s*{\s*today\s*:\s*{\s*(low\s*:\s*lowToday[^}]*|[^,]*,\s*low\s*:\s*lowToday\s*)},?\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g ) ); ``` @@ -63,7 +63,7 @@ assert( ```js assert( code.match( - /(var|const|let)\s*{\s*today\s*:\s*{\s*(high\s*:\s*highToday[^}]*|[^,]*,\s*high\s*:\s*highToday\s*)}\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g + /(var|const|let)\s*{\s*today\s*:\s*{\s*(high\s*:\s*highToday[^}]*|[^,]*,\s*high\s*:\s*highToday,?\s*)},?\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g ) ); ``` diff --git a/curriculum/challenges/arabic/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md b/curriculum/challenges/arabic/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md index 7e8bea5482e..49d59948762 100644 --- a/curriculum/challenges/arabic/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md +++ b/curriculum/challenges/arabic/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md @@ -56,46 +56,57 @@ hexagonalTile(10); # --solutions-- ```js -const NUM_PRIMES = 840000; -const PRIME_SEIVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SEIVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) { - PRIME_SEIVE[j] = false; +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); + + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } } } - } -})(NUM_PRIMES); -function isPrime(num) { - if (num === 2) return true; - else if (num % 2 === 0) return false - else return PRIME_SEIVE[(num - 3) / 2]; -} + this._seive = seive; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } +}; function hexagonalTile(tileIndex) { + const primeSeive = new PrimeSeive(tileIndex * 420); let count = 1; let n = 1; let number = 0; while (count < tileIndex) { - if (isPrime(6*n - 1) && - isPrime(6*n + 1) && - isPrime(12*n + 5)) { + if (primeSeive.isPrime(6*n - 1) && + primeSeive.isPrime(6*n + 1) && + primeSeive.isPrime(12*n + 5)) { number = 3*n*n - 3*n + 2; count++; if (count >= tileIndex) break; } - if (isPrime(6*n + 5) && - isPrime(6*n - 1) && - isPrime(12*n - 7) && n != 1) { + if (primeSeive.isPrime(6*n + 5) && + primeSeive.isPrime(6*n - 1) && + primeSeive.isPrime(12*n - 7) && n != 1) { number = 3*n*n + 3*n + 1; count++; } diff --git a/curriculum/challenges/arabic/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md b/curriculum/challenges/arabic/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md index 978b7affd9b..3b79403a4ea 100644 --- a/curriculum/challenges/arabic/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md +++ b/curriculum/challenges/arabic/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md @@ -67,25 +67,28 @@ distinctPrimeFactors(4, 4); # --solutions-- ```js -// Initalize factor count with seive -const NUMFACTORS = Array(135000).fill(0); -(function initFactors(num) { - for (let i = 2; i < num; i++) - if (NUMFACTORS[i] === 0) - for (let j = i; j < num; j += i) - NUMFACTORS[j]++; -})(135000); - function distinctPrimeFactors(targetNumPrimes, targetConsecutive) { + const primeLimit = targetNumPrimes * targetConsecutive * 10000; + const numFactors = Array(primeLimit).fill(0); + let numConsecutive = 0; - let currNumber = 10; - while (numConsecutive < targetConsecutive) { - if (NUMFACTORS[currNumber] === targetNumPrimes) + for (let i = 2; i < primeLimit; i++) { + if (numFactors[i] === targetNumPrimes) { + // Current number is composite with target num factors numConsecutive++; - else + if (numConsecutive === targetConsecutive) { + return i - numConsecutive + 1; + } + } else { + // Current number is not matching composite numConsecutive = 0; - currNumber++; + if (numFactors[i] === 0) { + // Current number is prime + for (let j = i; j < primeLimit; j += i) { + numFactors[j]++; + } + } + } } - return currNumber - targetConsecutive; } ``` diff --git a/curriculum/challenges/arabic/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md b/curriculum/challenges/arabic/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md index 861a3e99a8e..7cd5bc67b14 100644 --- a/curriculum/challenges/arabic/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md +++ b/curriculum/challenges/arabic/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md @@ -54,40 +54,56 @@ consecutivePrimeSum(1000000); # --solutions-- ```js -// Initalize prime number list with sieve -const NUM_PRIMES = 1000000; -const PRIMES = [2]; -const PRIME_SIEVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SIEVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - PRIMES.push(prime); - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) - PRIME_SIEVE[j] = false; - } - } - for (let i = sqrtUpper + 1; i < upper; i++) { - if (PRIME_SIEVE[i]) - PRIMES.push(2 * i + 3); - } -})(NUM_PRIMES); +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const primes = [2]; + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); -function isPrime(num) { - if (num === 2) - return true; - else if (num % 2 === 0) - return false - else - return PRIME_SIEVE[(num - 3) / 2]; -} + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + primes.push(prime); + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } + } + } + for (let i = sqrtUpper + 1; i < upper; i++) { + if (seive[i]) { + primes.push(2 * i + 3); + } + } + + this._seive = seive; + this._primes = primes; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } + + get primes() { + return this._primes; + } +}; function consecutivePrimeSum(limit) { + // Initalize seive + const primeSeive = new PrimeSeive(limit); + // Initalize for longest sum < 100 let bestPrime = 41; let bestI = 0; @@ -102,20 +118,20 @@ function consecutivePrimeSum(limit) { // -- Loop while pushing j towards end of PRIMES list // keeping sum under limit while (currSum < limit) { - if (isPrime(currSum)) { + if (primeSeive.isPrime(currSum)) { bestPrime = sumOfCurrRange = currSum; bestI = i; bestJ = j; } // -- Increment inner loop j++; - currSum += PRIMES[j]; + currSum += primeSeive.primes[j]; } // -- Increment outer loop i++; j = i + (bestJ - bestI); - sumOfCurrRange -= PRIMES[i - 1]; - sumOfCurrRange += PRIMES[j]; + sumOfCurrRange -= primeSeive.primes[i - 1]; + sumOfCurrRange += primeSeive.primes[j]; } // Return return bestPrime; diff --git a/curriculum/challenges/arabic/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md b/curriculum/challenges/arabic/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md index 26aed0ce89a..cdbfc3e568b 100644 --- a/curriculum/challenges/arabic/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md +++ b/curriculum/challenges/arabic/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md @@ -56,31 +56,43 @@ primeDigitReplacements(6); # --solutions-- ```js -const NUM_PRIMES = 1000000; -const PRIME_SEIVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SEIVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) { - PRIME_SEIVE[j] = false; +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); + + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } } } - } -})(NUM_PRIMES); -function isPrime(num) { - if (num === 2) return true; - else if (num % 2 === 0) return false - else return PRIME_SEIVE[(num - 3) / 2]; -} + this._seive = seive; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } +}; function primeDigitReplacements(n) { + const primeSeive = new PrimeSeive(n * n * n * 2000); + function isNFamily(number, n) { const prime = number.toString(); const lastDigit = prime[prime.length - 1]; @@ -114,12 +126,12 @@ function primeDigitReplacements(n) { function isPartOfFamily(number, prime) { return ( - isPrime(number) && number.toString().length === prime.length + primeSeive.isPrime(number) && number.toString().length === prime.length ); } for (let number = 1; number < 125000; number++) { - if (isPrime(number) && isNFamily(number, n)) { + if (primeSeive.isPrime(number) && isNFamily(number, n)) { return number; } } diff --git a/curriculum/challenges/arabic/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md b/curriculum/challenges/arabic/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md index ce6adc7cda6..87edd2d2956 100644 --- a/curriculum/challenges/arabic/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md +++ b/curriculum/challenges/arabic/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md @@ -119,7 +119,7 @@ const el = document.getElementById('email') assert(!!el && el.required) ``` -يجب أن يكون `#email` الخاص بك فرع من `#survey-form` +Your `#email` should be a descendant of `#survey-form`. ```js const el = document.querySelector('#survey-form #email') diff --git a/curriculum/challenges/arabic/14-responsive-web-design-22/learn-css-flexbox-by-building-a-photo-gallery/61537c9eecea6a335db6da79.md b/curriculum/challenges/arabic/14-responsive-web-design-22/learn-css-flexbox-by-building-a-photo-gallery/61537c9eecea6a335db6da79.md index 472e09d230d..03ac09c5a62 100644 --- a/curriculum/challenges/arabic/14-responsive-web-design-22/learn-css-flexbox-by-building-a-photo-gallery/61537c9eecea6a335db6da79.md +++ b/curriculum/challenges/arabic/14-responsive-web-design-22/learn-css-flexbox-by-building-a-photo-gallery/61537c9eecea6a335db6da79.md @@ -7,7 +7,7 @@ dashedName: step-5 # --description-- -Below your `.header` element, create a new `div` element and assign it a `class` of `gallery`. سيكون `div` حاوية لصور المَعْرِض. +أسفل عنصرك `.header`، أنشئ عنصر `div` جديد مع `class` يسمى `gallery`. سيكون `div` حاوية لصور المَعْرِض. في عنصر `.gallery`، أنشئ تسع عناصر `img`. diff --git a/curriculum/challenges/arabic/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98d5.md b/curriculum/challenges/arabic/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98d5.md index 8af55362cd3..955754aeda8 100644 --- a/curriculum/challenges/arabic/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98d5.md +++ b/curriculum/challenges/arabic/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98d5.md @@ -7,7 +7,7 @@ dashedName: step-13 # --description-- -Center the parts of your building by turning the `.bb1` element into a flexbox parent. Use the `flex-direction` and `align-items` properties to center the children. +ضع أجزاء مبناك بالمنتصف بتغير عنصر `.bb1` إلى عنصر حاوي بتركيب flexbox. استخدم خصائص `flex-direction` و `align-items` لوضع العنصر الفرعي. # --hints-- diff --git a/curriculum/challenges/arabic/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md b/curriculum/challenges/arabic/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md index 3f03a524e45..6543a8e156f 100644 --- a/curriculum/challenges/arabic/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md +++ b/curriculum/challenges/arabic/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md @@ -7,7 +7,7 @@ dashedName: step-22 # --description-- -إنشاء مُتغير جديد أسفل المُتغير الآخر يسمى `--building-color2` وإعطائه قيمة `#66cc99`. ثم عيّنها كخاصية `background-color` لعنصر `.bb2`. +Create a new variable below your `--building-color1` variable. Name your new variable `--building-color2` and give it a value of `#66cc99`. Then set it as the `background-color` of `.bb2`. # --hints-- @@ -17,7 +17,7 @@ dashedName: step-22 assert.exists(new __helpers.CSSHelp(document).isPropertyUsed('--building-color2')); ``` -يجب عليك إعطاء `--building-color2` قيمة `#66cc99`. +You should give `--building-color2` a value of `#66cc99` within the `.bb1` class. ```js assert.equal(new __helpers.CSSHelp(document).getStyle('.bb1')?.getPropertyValue('--building-color2').trim(), '#66cc99'); diff --git a/curriculum/challenges/arabic/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md b/curriculum/challenges/arabic/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md index 1240152dffb..04d45767cf2 100644 --- a/curriculum/challenges/arabic/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md +++ b/curriculum/challenges/arabic/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md @@ -51,7 +51,17 @@ assert( assert($('input')[0].hasAttribute('type')); ``` -عنصر `input` الخاص بك يجب أن يحتوي على سمة `type` بقيمة `radio`. إما أنك حذفت القيمة أو لديك خطأ إملائي. تذكر أن قيم السمة يجب أن تكون محاطة بعلامات اقتباس. +Your new `input` element should have only one `type` attribute. Remove any extras. + +```js +assert($('input')[0] + .getAttributeNames() + .filter(attr => attr === 'type') + .length === 1 +); +``` + +Your new `input` element should have a `type` attribute with the value `radio`. You have either omitted the value or have a typo. Remember that attribute values should be surrounded with quotation marks. ```js assert( @@ -61,20 +71,20 @@ assert( ); ``` -على الرغم من أنك قمت بتعيين عنصر `input` سمة `type` إلى `radio`، يوصى بأن تحيط دائما قيمة السمة بعلامات اقتباس. +Although you have set the new `input` element's `type` attribute to `radio`, it is recommended to always surround the value of an attribute with quotation marks. ```js assert(!/\<\s*input\s+type\s*=\s*radio/i.test(code)); ``` -يجب أن يتواجد النص `Indoor` لزر الـ `radio`، بعد الرز وليس قبله. +The `radio` button's `Indoor` text should be located after it instead of before it. ```js const radioInputElem = $('input')[0]; assert(!radioInputElem.previousSibling.nodeValue.match(/Indoor/i)); ``` -النص `Indoor` يجب أن يكون مباشرة على يمين زر الـ `radio`. إما أنك حذفت النص أو لديك خطأ إملائي. +The text `Indoor` should be located directly to the right of your `radio` button. You have either omitted the text or have a typo. ```js const radioInputElem = $('input')[0]; @@ -125,6 +135,7 @@ assert(

Cat Form

--fcc-editable-region-- + --fcc-editable-region-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md index 02ffeb838f6..bb4bb752806 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md @@ -7,7 +7,7 @@ dashedName: step-154 # --description-- -Use the `+=` operator to add `Your [weapon] breaks.` to the end of `text.innerText`, replacing `weapon` with the last item in the `inventory` array. You can get this last item by using `inventory.pop()`, which will remove the last item in the array AND return it so it appears in your string. +Use the `+=` operator to add `Your [weapon] breaks.`, with a space in front of `Your`, to the end of `text.innerText`. Replace `[weapon]` with the last item in the `inventory` array using `inventory.pop()`, which will remove the last item in the array AND return it so it appears in your string. # --hints-- @@ -24,7 +24,7 @@ You should use the `pop` method on the `inventory` array. assert.match(attack.toString(), /inventory\.pop\(\)/); ``` -You should add the string " Your " to `text.innerText`. Remember that spacing matters. +You should add `Your`, with a space before and after it, to `text.innerText`. ```js assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1/); @@ -37,7 +37,7 @@ console.log(attack.toString()); assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1\s*\+\s*inventory\.pop\(\)/); ``` -You should add `breaks.` to the `"Your " + inventory.pop()` string. +You should add `breaks.`, with a space in front of it, to the end of your string. ```js assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1\s*\+\s*inventory\.pop\(\)\s*\+\s*('|")\sbreaks\.\2/); diff --git a/curriculum/challenges/chinese-traditional/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md b/curriculum/challenges/chinese-traditional/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md index a8bb0cf51a9..fb2c55b2dd3 100644 --- a/curriculum/challenges/chinese-traditional/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md +++ b/curriculum/challenges/chinese-traditional/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md @@ -119,7 +119,7 @@ const el = document.getElementById('email') assert(!!el && el.required) ``` -你的 `#email` 元素應該是 `#survey-form` 元素的子元素。 +Your `#email` should be a descendant of `#survey-form`. ```js const el = document.querySelector('#survey-form #email') diff --git a/curriculum/challenges/chinese-traditional/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md b/curriculum/challenges/chinese-traditional/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md index eb1db1ed4bd..efc74c3fe25 100644 --- a/curriculum/challenges/chinese-traditional/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md +++ b/curriculum/challenges/chinese-traditional/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md @@ -53,7 +53,7 @@ assert( ```js assert( code.match( - /(var|const|let)\s*{\s*today\s*:\s*{\s*(low\s*:\s*lowToday[^}]*|[^,]*,\s*low\s*:\s*lowToday\s*)}\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g + /(var|const|let)\s*{\s*today\s*:\s*{\s*(low\s*:\s*lowToday[^}]*|[^,]*,\s*low\s*:\s*lowToday\s*)},?\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g ) ); ``` @@ -63,7 +63,7 @@ assert( ```js assert( code.match( - /(var|const|let)\s*{\s*today\s*:\s*{\s*(high\s*:\s*highToday[^}]*|[^,]*,\s*high\s*:\s*highToday\s*)}\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g + /(var|const|let)\s*{\s*today\s*:\s*{\s*(high\s*:\s*highToday[^}]*|[^,]*,\s*high\s*:\s*highToday,?\s*)},?\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g ) ); ``` diff --git a/curriculum/challenges/chinese-traditional/10-coding-interview-prep/algorithms/find-the-symmetric-difference.md b/curriculum/challenges/chinese-traditional/10-coding-interview-prep/algorithms/find-the-symmetric-difference.md index 4b78a2b2abe..02d7bf87193 100644 --- a/curriculum/challenges/chinese-traditional/10-coding-interview-prep/algorithms/find-the-symmetric-difference.md +++ b/curriculum/challenges/chinese-traditional/10-coding-interview-prep/algorithms/find-the-symmetric-difference.md @@ -54,7 +54,7 @@ assert.sameMembers(sym([1, 2, 3], [5, 2, 1, 4, 5]), [3, 4, 5]); assert.equal(sym([1, 2, 3], [5, 2, 1, 4, 5]).length, 3); ``` -`sym([1, 2, 5], [2, 3, 5], [3, 4, 5])` should return `[1, 4, 5]`. +`sym([1, 2, 5], [2, 3, 5], [3, 4, 5])` 應該返回 `[1, 4, 5]` 。 ```js assert.sameMembers(sym([1, 2, 5], [2, 3, 5], [3, 4, 5]), [1, 4, 5]); diff --git a/curriculum/challenges/chinese-traditional/10-coding-interview-prep/algorithms/implement-binary-search.md b/curriculum/challenges/chinese-traditional/10-coding-interview-prep/algorithms/implement-binary-search.md index bd2e8306ee1..6994926d584 100644 --- a/curriculum/challenges/chinese-traditional/10-coding-interview-prep/algorithms/implement-binary-search.md +++ b/curriculum/challenges/chinese-traditional/10-coding-interview-prep/algorithms/implement-binary-search.md @@ -1,6 +1,6 @@ --- id: 61abc7ebf3029b56226de5b6 -title: Implement Binary Search +title: 實現二分搜索 challengeType: 1 forumTopicId: 487618 dashedName: implement-binary-search @@ -8,25 +8,25 @@ dashedName: implement-binary-search # --description-- -Binary search is an **O(log(n))** efficiency algorithm for searching a sorted array to find an element. It operates using the following steps: +二分搜索是一種 **O(log(n))** 效率的算法,用於在已排序的數組以查找元素。 它通過以下步驟運行: -1. Find the middle `value` of a sorted array. If `value == target` return (found it!). -1. If middle `value < target`, search right half of array in next compare. -1. If middle `value > target`, search left half of array in next compare. +1. 查找已排序數組的中間值 `value`。 如果 `value == target`,則返回(找到了!)。 +1. 如果中間值 `value < target`,則在下一次比較中搜索數組的右半部分。 +1. 如果中間值 `value > target`,則在下一次比較中搜索數組的左半部分。 -As you can see, you are successively halving an array, which gives you the log(n) efficiency. For this challenge, we want you to show your work - how you got to the target value... the path you took! +如你所見,你連續將數組減半,這爲你提供了 log(n) 效率。 對於這個挑戰,我們希望你展示你的工作——你是如何到達目標值的……你走過的路! # --instructions-- -Write a function `binarySearch` that implements the binary search algorithm on an array, returning the path you took (each middle value comparison) to find the target in an array. +編寫一個函數 `binarySearch` 來實現對數組的二分查找算法,返回在數組中查找目標所採用的路徑(每個中間值比較)。 -The function takes a sorted array of integers and a target value as input. It returns an array containing (in-order) the middle value you found at each halving of the original array until you found the target value. The target value should be the last element of the returned array. If value not is found, return the string `Value Not Found`. +該函數將一個排序的整數數組和一個目標值作爲輸入。 它返回一個數組,其中包含(按順序)你在原始數組的每個減半處找到的中間值,直到你找到目標值。 目標值應該是返回數組的最後一個元素。 如果未找到值,則返回字符串 `Value Not Found`。 -For example, `binarySearch([1,2,3,4,5,6,7], 5)` would return `[4,6,5]`. +例如,`binarySearch([1,2,3,4,5,6,7], 5)` 將返回 `[4,6,5]`。 -For this challenge, when halving, you MUST use `Math.floor()` when doing division: `Math.floor(x/2)`. This will give a consistent, testable path. +對於這個挑戰,當減半時,你必須在做除法時使用 `Math.floor()`:`Math.floor(x/2)`。 這將提供一致的、可測試的路徑。 -**Note:** The following array will be used in tests: +**注意:** 以下數組將用於測試: ```js const testArray = [ @@ -37,50 +37,50 @@ const testArray = [ # --hints-- -`binarySearch` should be a function. +`binarySearch` 應該是一個函數。 ```js assert(typeof binarySearch == 'function'); ``` -`binarySearch(testArray, 0)` should return `[13, 5, 2, 0]`. +`binarySearch(testArray, 0)` 應該返回 `[13, 5, 2, 0]`。 ```js assert.deepEqual(binarySearch(_testArray, 0), [13, 5, 2, 0]); ``` -`binarySearch(testArray, 1)` should return `[13, 5, 2, 0, 1]`. +`binarySearch(testArray, 1)` 應該返回 `[13, 5, 2, 0, 1]`。 ```js assert.deepEqual(binarySearch(_testArray, 1), [13, 5, 2, 0, 1]); ``` -`binarySearch(testArray, 2)` should return `[13, 5, 2]`. +`binarySearch(testArray, 2)` 應該返回 `[13, 5, 2]`。 ```js assert.deepEqual(binarySearch(_testArray, 2), [13, 5, 2]); ``` -`binarySearch(testArray, 6)` should return the string `Value Not Found`. +`binarySearch(testArray, 6)` 應該返回字符串 `Value Not Found`。 ```js assert.strictEqual(binarySearch(_testArray, 6), 'Value Not Found'); ``` -`binarySearch(testArray, 11)` should return `[13, 5, 10, 11]`. +`binarySearch(testArray, 11)` 應該返回 `[13, 5, 10, 11]`。 ```js assert.deepEqual(binarySearch(_testArray, 11), [13, 5, 10, 11]) ``` -`binarySearch(testArray, 13)` should return `[13]`. +`binarySearch(testArray, 13)` 應該返回 `[13]`。 ```js assert.deepEqual(binarySearch(_testArray, 13), [13]); ``` -`binarySearch(testArray, 70)` should return `[13, 19, 22, 49, 70]`. +`binarySearch(testArray, 70)` 應該返回 `[13, 19, 22, 49, 70]`. ```js assert.deepEqual(binarySearch(_testArray, 70), [13, 19, 22, 49, 70]); diff --git a/curriculum/challenges/chinese-traditional/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md b/curriculum/challenges/chinese-traditional/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md index e3c053e56de..0e3bae915a9 100644 --- a/curriculum/challenges/chinese-traditional/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md +++ b/curriculum/challenges/chinese-traditional/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md @@ -56,46 +56,57 @@ hexagonalTile(10); # --solutions-- ```js -const NUM_PRIMES = 840000; -const PRIME_SEIVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SEIVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) { - PRIME_SEIVE[j] = false; +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); + + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } } } - } -})(NUM_PRIMES); -function isPrime(num) { - if (num === 2) return true; - else if (num % 2 === 0) return false - else return PRIME_SEIVE[(num - 3) / 2]; -} + this._seive = seive; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } +}; function hexagonalTile(tileIndex) { + const primeSeive = new PrimeSeive(tileIndex * 420); let count = 1; let n = 1; let number = 0; while (count < tileIndex) { - if (isPrime(6*n - 1) && - isPrime(6*n + 1) && - isPrime(12*n + 5)) { + if (primeSeive.isPrime(6*n - 1) && + primeSeive.isPrime(6*n + 1) && + primeSeive.isPrime(12*n + 5)) { number = 3*n*n - 3*n + 2; count++; if (count >= tileIndex) break; } - if (isPrime(6*n + 5) && - isPrime(6*n - 1) && - isPrime(12*n - 7) && n != 1) { + if (primeSeive.isPrime(6*n + 5) && + primeSeive.isPrime(6*n - 1) && + primeSeive.isPrime(12*n - 7) && n != 1) { number = 3*n*n + 3*n + 1; count++; } diff --git a/curriculum/challenges/chinese-traditional/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md b/curriculum/challenges/chinese-traditional/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md index 978b7affd9b..3b79403a4ea 100644 --- a/curriculum/challenges/chinese-traditional/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md +++ b/curriculum/challenges/chinese-traditional/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md @@ -67,25 +67,28 @@ distinctPrimeFactors(4, 4); # --solutions-- ```js -// Initalize factor count with seive -const NUMFACTORS = Array(135000).fill(0); -(function initFactors(num) { - for (let i = 2; i < num; i++) - if (NUMFACTORS[i] === 0) - for (let j = i; j < num; j += i) - NUMFACTORS[j]++; -})(135000); - function distinctPrimeFactors(targetNumPrimes, targetConsecutive) { + const primeLimit = targetNumPrimes * targetConsecutive * 10000; + const numFactors = Array(primeLimit).fill(0); + let numConsecutive = 0; - let currNumber = 10; - while (numConsecutive < targetConsecutive) { - if (NUMFACTORS[currNumber] === targetNumPrimes) + for (let i = 2; i < primeLimit; i++) { + if (numFactors[i] === targetNumPrimes) { + // Current number is composite with target num factors numConsecutive++; - else + if (numConsecutive === targetConsecutive) { + return i - numConsecutive + 1; + } + } else { + // Current number is not matching composite numConsecutive = 0; - currNumber++; + if (numFactors[i] === 0) { + // Current number is prime + for (let j = i; j < primeLimit; j += i) { + numFactors[j]++; + } + } + } } - return currNumber - targetConsecutive; } ``` diff --git a/curriculum/challenges/chinese-traditional/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md b/curriculum/challenges/chinese-traditional/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md index 861a3e99a8e..7cd5bc67b14 100644 --- a/curriculum/challenges/chinese-traditional/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md +++ b/curriculum/challenges/chinese-traditional/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md @@ -54,40 +54,56 @@ consecutivePrimeSum(1000000); # --solutions-- ```js -// Initalize prime number list with sieve -const NUM_PRIMES = 1000000; -const PRIMES = [2]; -const PRIME_SIEVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SIEVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - PRIMES.push(prime); - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) - PRIME_SIEVE[j] = false; - } - } - for (let i = sqrtUpper + 1; i < upper; i++) { - if (PRIME_SIEVE[i]) - PRIMES.push(2 * i + 3); - } -})(NUM_PRIMES); +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const primes = [2]; + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); -function isPrime(num) { - if (num === 2) - return true; - else if (num % 2 === 0) - return false - else - return PRIME_SIEVE[(num - 3) / 2]; -} + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + primes.push(prime); + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } + } + } + for (let i = sqrtUpper + 1; i < upper; i++) { + if (seive[i]) { + primes.push(2 * i + 3); + } + } + + this._seive = seive; + this._primes = primes; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } + + get primes() { + return this._primes; + } +}; function consecutivePrimeSum(limit) { + // Initalize seive + const primeSeive = new PrimeSeive(limit); + // Initalize for longest sum < 100 let bestPrime = 41; let bestI = 0; @@ -102,20 +118,20 @@ function consecutivePrimeSum(limit) { // -- Loop while pushing j towards end of PRIMES list // keeping sum under limit while (currSum < limit) { - if (isPrime(currSum)) { + if (primeSeive.isPrime(currSum)) { bestPrime = sumOfCurrRange = currSum; bestI = i; bestJ = j; } // -- Increment inner loop j++; - currSum += PRIMES[j]; + currSum += primeSeive.primes[j]; } // -- Increment outer loop i++; j = i + (bestJ - bestI); - sumOfCurrRange -= PRIMES[i - 1]; - sumOfCurrRange += PRIMES[j]; + sumOfCurrRange -= primeSeive.primes[i - 1]; + sumOfCurrRange += primeSeive.primes[j]; } // Return return bestPrime; diff --git a/curriculum/challenges/chinese-traditional/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md b/curriculum/challenges/chinese-traditional/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md index 26aed0ce89a..cdbfc3e568b 100644 --- a/curriculum/challenges/chinese-traditional/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md +++ b/curriculum/challenges/chinese-traditional/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md @@ -56,31 +56,43 @@ primeDigitReplacements(6); # --solutions-- ```js -const NUM_PRIMES = 1000000; -const PRIME_SEIVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SEIVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) { - PRIME_SEIVE[j] = false; +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); + + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } } } - } -})(NUM_PRIMES); -function isPrime(num) { - if (num === 2) return true; - else if (num % 2 === 0) return false - else return PRIME_SEIVE[(num - 3) / 2]; -} + this._seive = seive; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } +}; function primeDigitReplacements(n) { + const primeSeive = new PrimeSeive(n * n * n * 2000); + function isNFamily(number, n) { const prime = number.toString(); const lastDigit = prime[prime.length - 1]; @@ -114,12 +126,12 @@ function primeDigitReplacements(n) { function isPartOfFamily(number, prime) { return ( - isPrime(number) && number.toString().length === prime.length + primeSeive.isPrime(number) && number.toString().length === prime.length ); } for (let number = 1; number < 125000; number++) { - if (isPrime(number) && isNFamily(number, n)) { + if (primeSeive.isPrime(number) && isNFamily(number, n)) { return number; } } diff --git a/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md b/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md index a8bb0cf51a9..fb2c55b2dd3 100644 --- a/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md +++ b/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md @@ -119,7 +119,7 @@ const el = document.getElementById('email') assert(!!el && el.required) ``` -你的 `#email` 元素應該是 `#survey-form` 元素的子元素。 +Your `#email` should be a descendant of `#survey-form`. ```js const el = document.querySelector('#survey-form #email') diff --git a/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/learn-accessibility-by-building-a-quiz/6147a14ef5668b5881ef2297.md b/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/learn-accessibility-by-building-a-quiz/6147a14ef5668b5881ef2297.md index e28f5714ca2..270d34235bf 100644 --- a/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/learn-accessibility-by-building-a-quiz/6147a14ef5668b5881ef2297.md +++ b/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/learn-accessibility-by-building-a-quiz/6147a14ef5668b5881ef2297.md @@ -26,7 +26,7 @@ const gs = (s) => new __helpers.CSSHelp(document).getStyle(s); assert.exists(gs('nav > ul > li:hover') || gs('nav li:hover')); ``` -你應該給懸停的 `li` 元素設置 `background-color` 值爲 `#dfdfe2`。 +你應該爲懸停的 `li` 元素設置 `background-color` 值爲 `#dfdfe2`。 ```js const gs = (s) => new __helpers.CSSHelp(document).getStyle(s); @@ -42,7 +42,7 @@ const color = gs('nav > ul > li:hover')?.color ?? gs('nav li:hover')?.color; assert.equal(color, 'rgb(27, 27, 50)'); ``` -你應該給懸停的 `li` 元素設置 `pointer` 值爲 `cursor`。 +你應該爲懸停的 `li` 元素設置 `cursor` 值爲 `pointer`。 ```js const gs = (s) => new __helpers.CSSHelp(document).getStyle(s); diff --git a/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/learn-css-flexbox-by-building-a-photo-gallery/61537c9eecea6a335db6da79.md b/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/learn-css-flexbox-by-building-a-photo-gallery/61537c9eecea6a335db6da79.md index 679810e89a5..f194b862211 100644 --- a/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/learn-css-flexbox-by-building-a-photo-gallery/61537c9eecea6a335db6da79.md +++ b/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/learn-css-flexbox-by-building-a-photo-gallery/61537c9eecea6a335db6da79.md @@ -7,7 +7,7 @@ dashedName: step-5 # --description-- -Below your `.header` element, create a new `div` element and assign it a `class` of `gallery`. 這個 `div` 將作爲相冊的容器。 +在 `.header` 元素下面,創建一個 `class` 設置爲 `gallery` 的 `div` 元素。 這個 `div` 將作爲相冊的容器。 在該 `.gallery` 元素中,創建九個 `img` 元素。 diff --git a/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md b/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md index bc531a614f4..840c19c5d4b 100644 --- a/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md +++ b/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md @@ -7,7 +7,7 @@ dashedName: step-22 # --description-- -在另一個名爲 `--building-color2` 的變量下方創建一個新變量,併爲其賦值 `#66cc99`。 然後將它設置爲 `.bb2` 的 `background-color`。 +Create a new variable below your `--building-color1` variable. Name your new variable `--building-color2` and give it a value of `#66cc99`. Then set it as the `background-color` of `.bb2`. # --hints-- @@ -17,7 +17,7 @@ dashedName: step-22 assert.exists(new __helpers.CSSHelp(document).isPropertyUsed('--building-color2')); ``` -你應該將 `--building-color2` 的值設置爲 `#66cc99`。 +You should give `--building-color2` a value of `#66cc99` within the `.bb1` class. ```js assert.equal(new __helpers.CSSHelp(document).getStyle('.bb1')?.getPropertyValue('--building-color2').trim(), '#66cc99'); diff --git a/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md b/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md index 978c730f505..ba6bb182186 100644 --- a/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md +++ b/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md @@ -51,7 +51,17 @@ assert( assert($('input')[0].hasAttribute('type')); ``` -你的新 `input` 元素應該有一個 `type` 屬性,其值爲 `radio`。 你可能省略了這個值或者有拼寫錯誤。 請記住,屬性值應該放在引號中。 +Your new `input` element should have only one `type` attribute. Remove any extras. + +```js +assert($('input')[0] + .getAttributeNames() + .filter(attr => attr === 'type') + .length === 1 +); +``` + +Your new `input` element should have a `type` attribute with the value `radio`. You have either omitted the value or have a typo. Remember that attribute values should be surrounded with quotation marks. ```js assert( @@ -61,20 +71,20 @@ assert( ); ``` -儘管你已將新的 `input` 元素的 `type` 屬性設置爲 `radio`,但建議始終將屬性的值放在引號中。 +Although you have set the new `input` element's `type` attribute to `radio`, it is recommended to always surround the value of an attribute with quotation marks. ```js assert(!/\<\s*input\s+type\s*=\s*radio/i.test(code)); ``` -`radio` 按鈕的 `Indoor` 文本應該位於它之後而不是之前。 +The `radio` button's `Indoor` text should be located after it instead of before it. ```js const radioInputElem = $('input')[0]; assert(!radioInputElem.previousSibling.nodeValue.match(/Indoor/i)); ``` -`Indoor` 文本應直接位於 `radio` 按鈕的右側。 你可能忽略了文本或有拼寫錯誤。 +The text `Indoor` should be located directly to the right of your `radio` button. You have either omitted the text or have a typo. ```js const radioInputElem = $('input')[0]; @@ -125,6 +135,7 @@ assert(

Cat Form

--fcc-editable-region-- + --fcc-editable-region-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md index 02ffeb838f6..bb4bb752806 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md @@ -7,7 +7,7 @@ dashedName: step-154 # --description-- -Use the `+=` operator to add `Your [weapon] breaks.` to the end of `text.innerText`, replacing `weapon` with the last item in the `inventory` array. You can get this last item by using `inventory.pop()`, which will remove the last item in the array AND return it so it appears in your string. +Use the `+=` operator to add `Your [weapon] breaks.`, with a space in front of `Your`, to the end of `text.innerText`. Replace `[weapon]` with the last item in the `inventory` array using `inventory.pop()`, which will remove the last item in the array AND return it so it appears in your string. # --hints-- @@ -24,7 +24,7 @@ You should use the `pop` method on the `inventory` array. assert.match(attack.toString(), /inventory\.pop\(\)/); ``` -You should add the string " Your " to `text.innerText`. Remember that spacing matters. +You should add `Your`, with a space before and after it, to `text.innerText`. ```js assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1/); @@ -37,7 +37,7 @@ console.log(attack.toString()); assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1\s*\+\s*inventory\.pop\(\)/); ``` -You should add `breaks.` to the `"Your " + inventory.pop()` string. +You should add `breaks.`, with a space in front of it, to the end of your string. ```js assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1\s*\+\s*inventory\.pop\(\)\s*\+\s*('|")\sbreaks\.\2/); diff --git a/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md b/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md index d70515df0e7..7a88d6ee2d7 100644 --- a/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md +++ b/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md @@ -119,7 +119,7 @@ const el = document.getElementById('email') assert(!!el && el.required) ``` -你的 `#email` 元素应该是 `#survey-form` 元素的子元素。 +Your `#email` should be a descendant of `#survey-form`. ```js const el = document.querySelector('#survey-form #email') diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md index 7c5f5bd338d..6495c18edaf 100644 --- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md +++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md @@ -53,7 +53,7 @@ assert( ```js assert( code.match( - /(var|const|let)\s*{\s*today\s*:\s*{\s*(low\s*:\s*lowToday[^}]*|[^,]*,\s*low\s*:\s*lowToday\s*)}\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g + /(var|const|let)\s*{\s*today\s*:\s*{\s*(low\s*:\s*lowToday[^}]*|[^,]*,\s*low\s*:\s*lowToday\s*)},?\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g ) ); ``` @@ -63,7 +63,7 @@ assert( ```js assert( code.match( - /(var|const|let)\s*{\s*today\s*:\s*{\s*(high\s*:\s*highToday[^}]*|[^,]*,\s*high\s*:\s*highToday\s*)}\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g + /(var|const|let)\s*{\s*today\s*:\s*{\s*(high\s*:\s*highToday[^}]*|[^,]*,\s*high\s*:\s*highToday,?\s*)},?\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g ) ); ``` diff --git a/curriculum/challenges/chinese/10-coding-interview-prep/algorithms/find-the-symmetric-difference.md b/curriculum/challenges/chinese/10-coding-interview-prep/algorithms/find-the-symmetric-difference.md index 90e75400e9b..e288e2737e9 100644 --- a/curriculum/challenges/chinese/10-coding-interview-prep/algorithms/find-the-symmetric-difference.md +++ b/curriculum/challenges/chinese/10-coding-interview-prep/algorithms/find-the-symmetric-difference.md @@ -54,7 +54,7 @@ assert.sameMembers(sym([1, 2, 3], [5, 2, 1, 4, 5]), [3, 4, 5]); assert.equal(sym([1, 2, 3], [5, 2, 1, 4, 5]).length, 3); ``` -`sym([1, 2, 5], [2, 3, 5], [3, 4, 5])` should return `[1, 4, 5]`. +`sym([1, 2, 5], [2, 3, 5], [3, 4, 5])` 应该返回 `[1, 4, 5]` 。 ```js assert.sameMembers(sym([1, 2, 5], [2, 3, 5], [3, 4, 5]), [1, 4, 5]); diff --git a/curriculum/challenges/chinese/10-coding-interview-prep/algorithms/implement-binary-search.md b/curriculum/challenges/chinese/10-coding-interview-prep/algorithms/implement-binary-search.md index bd2e8306ee1..d0153acf95a 100644 --- a/curriculum/challenges/chinese/10-coding-interview-prep/algorithms/implement-binary-search.md +++ b/curriculum/challenges/chinese/10-coding-interview-prep/algorithms/implement-binary-search.md @@ -1,6 +1,6 @@ --- id: 61abc7ebf3029b56226de5b6 -title: Implement Binary Search +title: 实现二分搜索 challengeType: 1 forumTopicId: 487618 dashedName: implement-binary-search @@ -8,25 +8,25 @@ dashedName: implement-binary-search # --description-- -Binary search is an **O(log(n))** efficiency algorithm for searching a sorted array to find an element. It operates using the following steps: +二分搜索是一种 **O(log(n))** 效率的算法,用于在已排序的数组以查找元素。 它通过以下步骤运行: -1. Find the middle `value` of a sorted array. If `value == target` return (found it!). -1. If middle `value < target`, search right half of array in next compare. -1. If middle `value > target`, search left half of array in next compare. +1. 查找已排序数组的中间值 `value`。 如果 `value == target`,则返回(找到了!)。 +1. 如果中间值 `value < target`,则在下一次比较中搜索数组的右半部分。 +1. 如果中间值 `value > target`,则在下一次比较中搜索数组的左半部分。 -As you can see, you are successively halving an array, which gives you the log(n) efficiency. For this challenge, we want you to show your work - how you got to the target value... the path you took! +如你所见,你连续将数组减半,这为你提供了 log(n) 效率。 对于这个挑战,我们希望你展示你的工作——你是如何到达目标值的……你走过的路! # --instructions-- -Write a function `binarySearch` that implements the binary search algorithm on an array, returning the path you took (each middle value comparison) to find the target in an array. +编写一个函数 `binarySearch` 来实现对数组的二分查找算法,返回在数组中查找目标所采用的路径(每个中间值比较)。 -The function takes a sorted array of integers and a target value as input. It returns an array containing (in-order) the middle value you found at each halving of the original array until you found the target value. The target value should be the last element of the returned array. If value not is found, return the string `Value Not Found`. +该函数将一个排序的整数数组和一个目标值作为输入。 它返回一个数组,其中包含(按顺序)你在原始数组的每个减半处找到的中间值,直到你找到目标值。 目标值应该是返回数组的最后一个元素。 如果未找到值,则返回字符串 `Value Not Found`。 -For example, `binarySearch([1,2,3,4,5,6,7], 5)` would return `[4,6,5]`. +例如,`binarySearch([1,2,3,4,5,6,7], 5)` 将返回 `[4,6,5]`。 -For this challenge, when halving, you MUST use `Math.floor()` when doing division: `Math.floor(x/2)`. This will give a consistent, testable path. +对于这个挑战,当减半时,你必须在做除法时使用 `Math.floor()`:`Math.floor(x/2)`。 这将提供一致的、可测试的路径。 -**Note:** The following array will be used in tests: +**注意:** 以下数组将用于测试: ```js const testArray = [ @@ -37,50 +37,50 @@ const testArray = [ # --hints-- -`binarySearch` should be a function. +`binarySearch` 应该是一个函数。 ```js assert(typeof binarySearch == 'function'); ``` -`binarySearch(testArray, 0)` should return `[13, 5, 2, 0]`. +`binarySearch(testArray, 0)` 应该返回 `[13, 5, 2, 0]`。 ```js assert.deepEqual(binarySearch(_testArray, 0), [13, 5, 2, 0]); ``` -`binarySearch(testArray, 1)` should return `[13, 5, 2, 0, 1]`. +`binarySearch(testArray, 1)` 应该返回 `[13, 5, 2, 0, 1]`。 ```js assert.deepEqual(binarySearch(_testArray, 1), [13, 5, 2, 0, 1]); ``` -`binarySearch(testArray, 2)` should return `[13, 5, 2]`. +`binarySearch(testArray, 2)` 应该返回 `[13, 5, 2]`。 ```js assert.deepEqual(binarySearch(_testArray, 2), [13, 5, 2]); ``` -`binarySearch(testArray, 6)` should return the string `Value Not Found`. +`binarySearch(testArray, 6)` 应该返回字符串 `Value Not Found`。 ```js assert.strictEqual(binarySearch(_testArray, 6), 'Value Not Found'); ``` -`binarySearch(testArray, 11)` should return `[13, 5, 10, 11]`. +`binarySearch(testArray, 11)` 应该返回 `[13, 5, 10, 11]`。 ```js assert.deepEqual(binarySearch(_testArray, 11), [13, 5, 10, 11]) ``` -`binarySearch(testArray, 13)` should return `[13]`. +`binarySearch(testArray, 13)` 应该返回 `[13]`。 ```js assert.deepEqual(binarySearch(_testArray, 13), [13]); ``` -`binarySearch(testArray, 70)` should return `[13, 19, 22, 49, 70]`. +`binarySearch(testArray, 70)` 应该返回 `[13, 19, 22, 49, 70]`. ```js assert.deepEqual(binarySearch(_testArray, 70), [13, 19, 22, 49, 70]); diff --git a/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md b/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md index 5a5725b9ba5..e47f86ec958 100644 --- a/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md +++ b/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md @@ -56,46 +56,57 @@ hexagonalTile(10); # --solutions-- ```js -const NUM_PRIMES = 840000; -const PRIME_SEIVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SEIVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) { - PRIME_SEIVE[j] = false; +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); + + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } } } - } -})(NUM_PRIMES); -function isPrime(num) { - if (num === 2) return true; - else if (num % 2 === 0) return false - else return PRIME_SEIVE[(num - 3) / 2]; -} + this._seive = seive; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } +}; function hexagonalTile(tileIndex) { + const primeSeive = new PrimeSeive(tileIndex * 420); let count = 1; let n = 1; let number = 0; while (count < tileIndex) { - if (isPrime(6*n - 1) && - isPrime(6*n + 1) && - isPrime(12*n + 5)) { + if (primeSeive.isPrime(6*n - 1) && + primeSeive.isPrime(6*n + 1) && + primeSeive.isPrime(12*n + 5)) { number = 3*n*n - 3*n + 2; count++; if (count >= tileIndex) break; } - if (isPrime(6*n + 5) && - isPrime(6*n - 1) && - isPrime(12*n - 7) && n != 1) { + if (primeSeive.isPrime(6*n + 5) && + primeSeive.isPrime(6*n - 1) && + primeSeive.isPrime(12*n - 7) && n != 1) { number = 3*n*n + 3*n + 1; count++; } diff --git a/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md b/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md index 978b7affd9b..3b79403a4ea 100644 --- a/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md +++ b/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md @@ -67,25 +67,28 @@ distinctPrimeFactors(4, 4); # --solutions-- ```js -// Initalize factor count with seive -const NUMFACTORS = Array(135000).fill(0); -(function initFactors(num) { - for (let i = 2; i < num; i++) - if (NUMFACTORS[i] === 0) - for (let j = i; j < num; j += i) - NUMFACTORS[j]++; -})(135000); - function distinctPrimeFactors(targetNumPrimes, targetConsecutive) { + const primeLimit = targetNumPrimes * targetConsecutive * 10000; + const numFactors = Array(primeLimit).fill(0); + let numConsecutive = 0; - let currNumber = 10; - while (numConsecutive < targetConsecutive) { - if (NUMFACTORS[currNumber] === targetNumPrimes) + for (let i = 2; i < primeLimit; i++) { + if (numFactors[i] === targetNumPrimes) { + // Current number is composite with target num factors numConsecutive++; - else + if (numConsecutive === targetConsecutive) { + return i - numConsecutive + 1; + } + } else { + // Current number is not matching composite numConsecutive = 0; - currNumber++; + if (numFactors[i] === 0) { + // Current number is prime + for (let j = i; j < primeLimit; j += i) { + numFactors[j]++; + } + } + } } - return currNumber - targetConsecutive; } ``` diff --git a/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md b/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md index 861a3e99a8e..7cd5bc67b14 100644 --- a/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md +++ b/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md @@ -54,40 +54,56 @@ consecutivePrimeSum(1000000); # --solutions-- ```js -// Initalize prime number list with sieve -const NUM_PRIMES = 1000000; -const PRIMES = [2]; -const PRIME_SIEVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SIEVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - PRIMES.push(prime); - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) - PRIME_SIEVE[j] = false; - } - } - for (let i = sqrtUpper + 1; i < upper; i++) { - if (PRIME_SIEVE[i]) - PRIMES.push(2 * i + 3); - } -})(NUM_PRIMES); +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const primes = [2]; + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); -function isPrime(num) { - if (num === 2) - return true; - else if (num % 2 === 0) - return false - else - return PRIME_SIEVE[(num - 3) / 2]; -} + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + primes.push(prime); + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } + } + } + for (let i = sqrtUpper + 1; i < upper; i++) { + if (seive[i]) { + primes.push(2 * i + 3); + } + } + + this._seive = seive; + this._primes = primes; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } + + get primes() { + return this._primes; + } +}; function consecutivePrimeSum(limit) { + // Initalize seive + const primeSeive = new PrimeSeive(limit); + // Initalize for longest sum < 100 let bestPrime = 41; let bestI = 0; @@ -102,20 +118,20 @@ function consecutivePrimeSum(limit) { // -- Loop while pushing j towards end of PRIMES list // keeping sum under limit while (currSum < limit) { - if (isPrime(currSum)) { + if (primeSeive.isPrime(currSum)) { bestPrime = sumOfCurrRange = currSum; bestI = i; bestJ = j; } // -- Increment inner loop j++; - currSum += PRIMES[j]; + currSum += primeSeive.primes[j]; } // -- Increment outer loop i++; j = i + (bestJ - bestI); - sumOfCurrRange -= PRIMES[i - 1]; - sumOfCurrRange += PRIMES[j]; + sumOfCurrRange -= primeSeive.primes[i - 1]; + sumOfCurrRange += primeSeive.primes[j]; } // Return return bestPrime; diff --git a/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md b/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md index 26aed0ce89a..cdbfc3e568b 100644 --- a/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md +++ b/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md @@ -56,31 +56,43 @@ primeDigitReplacements(6); # --solutions-- ```js -const NUM_PRIMES = 1000000; -const PRIME_SEIVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SEIVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) { - PRIME_SEIVE[j] = false; +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); + + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } } } - } -})(NUM_PRIMES); -function isPrime(num) { - if (num === 2) return true; - else if (num % 2 === 0) return false - else return PRIME_SEIVE[(num - 3) / 2]; -} + this._seive = seive; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } +}; function primeDigitReplacements(n) { + const primeSeive = new PrimeSeive(n * n * n * 2000); + function isNFamily(number, n) { const prime = number.toString(); const lastDigit = prime[prime.length - 1]; @@ -114,12 +126,12 @@ function primeDigitReplacements(n) { function isPartOfFamily(number, prime) { return ( - isPrime(number) && number.toString().length === prime.length + primeSeive.isPrime(number) && number.toString().length === prime.length ); } for (let number = 1; number < 125000; number++) { - if (isPrime(number) && isNFamily(number, n)) { + if (primeSeive.isPrime(number) && isNFamily(number, n)) { return number; } } diff --git a/curriculum/challenges/chinese/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md b/curriculum/challenges/chinese/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md index d70515df0e7..7a88d6ee2d7 100644 --- a/curriculum/challenges/chinese/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md +++ b/curriculum/challenges/chinese/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md @@ -119,7 +119,7 @@ const el = document.getElementById('email') assert(!!el && el.required) ``` -你的 `#email` 元素应该是 `#survey-form` 元素的子元素。 +Your `#email` should be a descendant of `#survey-form`. ```js const el = document.querySelector('#survey-form #email') diff --git a/curriculum/challenges/chinese/14-responsive-web-design-22/learn-accessibility-by-building-a-quiz/6147a14ef5668b5881ef2297.md b/curriculum/challenges/chinese/14-responsive-web-design-22/learn-accessibility-by-building-a-quiz/6147a14ef5668b5881ef2297.md index a4620a841b4..ff45a9e8f59 100644 --- a/curriculum/challenges/chinese/14-responsive-web-design-22/learn-accessibility-by-building-a-quiz/6147a14ef5668b5881ef2297.md +++ b/curriculum/challenges/chinese/14-responsive-web-design-22/learn-accessibility-by-building-a-quiz/6147a14ef5668b5881ef2297.md @@ -26,7 +26,7 @@ const gs = (s) => new __helpers.CSSHelp(document).getStyle(s); assert.exists(gs('nav > ul > li:hover') || gs('nav li:hover')); ``` -你应该给悬停的 `li` 元素设置 `background-color` 值为 `#dfdfe2`。 +你应该为悬停的 `li` 元素设置 `background-color` 值为 `#dfdfe2`。 ```js const gs = (s) => new __helpers.CSSHelp(document).getStyle(s); @@ -42,7 +42,7 @@ const color = gs('nav > ul > li:hover')?.color ?? gs('nav li:hover')?.color; assert.equal(color, 'rgb(27, 27, 50)'); ``` -你应该给悬停的 `li` 元素设置 `pointer` 值为 `cursor`。 +你应该为悬停的 `li` 元素设置 `cursor` 值为 `pointer`。 ```js const gs = (s) => new __helpers.CSSHelp(document).getStyle(s); diff --git a/curriculum/challenges/chinese/14-responsive-web-design-22/learn-css-flexbox-by-building-a-photo-gallery/61537c9eecea6a335db6da79.md b/curriculum/challenges/chinese/14-responsive-web-design-22/learn-css-flexbox-by-building-a-photo-gallery/61537c9eecea6a335db6da79.md index 73f70747f5b..d9c9a181fc7 100644 --- a/curriculum/challenges/chinese/14-responsive-web-design-22/learn-css-flexbox-by-building-a-photo-gallery/61537c9eecea6a335db6da79.md +++ b/curriculum/challenges/chinese/14-responsive-web-design-22/learn-css-flexbox-by-building-a-photo-gallery/61537c9eecea6a335db6da79.md @@ -7,7 +7,7 @@ dashedName: step-5 # --description-- -Below your `.header` element, create a new `div` element and assign it a `class` of `gallery`. 这个 `div` 将作为相册的容器。 +在 `.header` 元素下面,创建一个 `class` 设置为 `gallery` 的 `div` 元素。 这个 `div` 将作为相册的容器。 在该 `.gallery` 元素中,创建九个 `img` 元素。 diff --git a/curriculum/challenges/chinese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md b/curriculum/challenges/chinese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md index 5964e33896e..2972c4b3d6c 100644 --- a/curriculum/challenges/chinese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md +++ b/curriculum/challenges/chinese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md @@ -7,7 +7,7 @@ dashedName: step-22 # --description-- -在另一个名为 `--building-color2` 的变量下方创建一个新变量,并为其赋值 `#66cc99`。 然后将它设置为 `.bb2` 的 `background-color`。 +Create a new variable below your `--building-color1` variable. Name your new variable `--building-color2` and give it a value of `#66cc99`. Then set it as the `background-color` of `.bb2`. # --hints-- @@ -17,7 +17,7 @@ dashedName: step-22 assert.exists(new __helpers.CSSHelp(document).isPropertyUsed('--building-color2')); ``` -你应该将 `--building-color2` 的值设置为 `#66cc99`。 +You should give `--building-color2` a value of `#66cc99` within the `.bb1` class. ```js assert.equal(new __helpers.CSSHelp(document).getStyle('.bb1')?.getPropertyValue('--building-color2').trim(), '#66cc99'); diff --git a/curriculum/challenges/chinese/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md b/curriculum/challenges/chinese/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md index bb9447de2af..c8d0d6bb549 100644 --- a/curriculum/challenges/chinese/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md +++ b/curriculum/challenges/chinese/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md @@ -51,7 +51,17 @@ assert( assert($('input')[0].hasAttribute('type')); ``` -你的新 `input` 元素应该有一个 `type` 属性,其值为 `radio`。 你可能省略了这个值或者有拼写错误。 请记住,属性值应该放在引号中。 +Your new `input` element should have only one `type` attribute. Remove any extras. + +```js +assert($('input')[0] + .getAttributeNames() + .filter(attr => attr === 'type') + .length === 1 +); +``` + +Your new `input` element should have a `type` attribute with the value `radio`. You have either omitted the value or have a typo. Remember that attribute values should be surrounded with quotation marks. ```js assert( @@ -61,20 +71,20 @@ assert( ); ``` -尽管你已将新的 `input` 元素的 `type` 属性设置为 `radio`,但建议始终将属性的值放在引号中。 +Although you have set the new `input` element's `type` attribute to `radio`, it is recommended to always surround the value of an attribute with quotation marks. ```js assert(!/\<\s*input\s+type\s*=\s*radio/i.test(code)); ``` -`radio` 按钮的 `Indoor` 文本应该位于它之后而不是之前。 +The `radio` button's `Indoor` text should be located after it instead of before it. ```js const radioInputElem = $('input')[0]; assert(!radioInputElem.previousSibling.nodeValue.match(/Indoor/i)); ``` -`Indoor` 文本应直接位于 `radio` 按钮的右侧。 你可能忽略了文本或有拼写错误。 +The text `Indoor` should be located directly to the right of your `radio` button. You have either omitted the text or have a typo. ```js const radioInputElem = $('input')[0]; @@ -125,6 +135,7 @@ assert(

Cat Form

--fcc-editable-region-- + --fcc-editable-region-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md index 02ffeb838f6..bb4bb752806 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md @@ -7,7 +7,7 @@ dashedName: step-154 # --description-- -Use the `+=` operator to add `Your [weapon] breaks.` to the end of `text.innerText`, replacing `weapon` with the last item in the `inventory` array. You can get this last item by using `inventory.pop()`, which will remove the last item in the array AND return it so it appears in your string. +Use the `+=` operator to add `Your [weapon] breaks.`, with a space in front of `Your`, to the end of `text.innerText`. Replace `[weapon]` with the last item in the `inventory` array using `inventory.pop()`, which will remove the last item in the array AND return it so it appears in your string. # --hints-- @@ -24,7 +24,7 @@ You should use the `pop` method on the `inventory` array. assert.match(attack.toString(), /inventory\.pop\(\)/); ``` -You should add the string " Your " to `text.innerText`. Remember that spacing matters. +You should add `Your`, with a space before and after it, to `text.innerText`. ```js assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1/); @@ -37,7 +37,7 @@ console.log(attack.toString()); assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1\s*\+\s*inventory\.pop\(\)/); ``` -You should add `breaks.` to the `"Your " + inventory.pop()` string. +You should add `breaks.`, with a space in front of it, to the end of your string. ```js assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1\s*\+\s*inventory\.pop\(\)\s*\+\s*('|")\sbreaks\.\2/); diff --git a/curriculum/challenges/espanol/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md b/curriculum/challenges/espanol/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md index a692dc18f03..7c3e1beb269 100644 --- a/curriculum/challenges/espanol/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md +++ b/curriculum/challenges/espanol/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md @@ -119,7 +119,7 @@ const el = document.getElementById('email') assert(!!el && el.required) ``` -Tu `#email` debe ser descendiente de `#survey-form` +Your `#email` should be a descendant of `#survey-form`. ```js const el = document.querySelector('#survey-form #email') diff --git a/curriculum/challenges/espanol/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md b/curriculum/challenges/espanol/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md index de1258d447d..ccee86b8f47 100644 --- a/curriculum/challenges/espanol/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md +++ b/curriculum/challenges/espanol/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md @@ -53,7 +53,7 @@ Debes usar desestructuración para crear la variable `lowToday`. ```js assert( code.match( - /(var|const|let)\s*{\s*today\s*:\s*{\s*(low\s*:\s*lowToday[^}]*|[^,]*,\s*low\s*:\s*lowToday\s*)}\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g + /(var|const|let)\s*{\s*today\s*:\s*{\s*(low\s*:\s*lowToday[^}]*|[^,]*,\s*low\s*:\s*lowToday\s*)},?\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g ) ); ``` @@ -63,7 +63,7 @@ Debes usar desestructuración para crear la variable `highToday`. ```js assert( code.match( - /(var|const|let)\s*{\s*today\s*:\s*{\s*(high\s*:\s*highToday[^}]*|[^,]*,\s*high\s*:\s*highToday\s*)}\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g + /(var|const|let)\s*{\s*today\s*:\s*{\s*(high\s*:\s*highToday[^}]*|[^,]*,\s*high\s*:\s*highToday,?\s*)},?\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g ) ); ``` diff --git a/curriculum/challenges/espanol/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md b/curriculum/challenges/espanol/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md index 7e8bea5482e..49d59948762 100644 --- a/curriculum/challenges/espanol/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md +++ b/curriculum/challenges/espanol/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md @@ -56,46 +56,57 @@ hexagonalTile(10); # --solutions-- ```js -const NUM_PRIMES = 840000; -const PRIME_SEIVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SEIVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) { - PRIME_SEIVE[j] = false; +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); + + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } } } - } -})(NUM_PRIMES); -function isPrime(num) { - if (num === 2) return true; - else if (num % 2 === 0) return false - else return PRIME_SEIVE[(num - 3) / 2]; -} + this._seive = seive; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } +}; function hexagonalTile(tileIndex) { + const primeSeive = new PrimeSeive(tileIndex * 420); let count = 1; let n = 1; let number = 0; while (count < tileIndex) { - if (isPrime(6*n - 1) && - isPrime(6*n + 1) && - isPrime(12*n + 5)) { + if (primeSeive.isPrime(6*n - 1) && + primeSeive.isPrime(6*n + 1) && + primeSeive.isPrime(12*n + 5)) { number = 3*n*n - 3*n + 2; count++; if (count >= tileIndex) break; } - if (isPrime(6*n + 5) && - isPrime(6*n - 1) && - isPrime(12*n - 7) && n != 1) { + if (primeSeive.isPrime(6*n + 5) && + primeSeive.isPrime(6*n - 1) && + primeSeive.isPrime(12*n - 7) && n != 1) { number = 3*n*n + 3*n + 1; count++; } diff --git a/curriculum/challenges/espanol/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md b/curriculum/challenges/espanol/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md index 978b7affd9b..3b79403a4ea 100644 --- a/curriculum/challenges/espanol/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md +++ b/curriculum/challenges/espanol/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md @@ -67,25 +67,28 @@ distinctPrimeFactors(4, 4); # --solutions-- ```js -// Initalize factor count with seive -const NUMFACTORS = Array(135000).fill(0); -(function initFactors(num) { - for (let i = 2; i < num; i++) - if (NUMFACTORS[i] === 0) - for (let j = i; j < num; j += i) - NUMFACTORS[j]++; -})(135000); - function distinctPrimeFactors(targetNumPrimes, targetConsecutive) { + const primeLimit = targetNumPrimes * targetConsecutive * 10000; + const numFactors = Array(primeLimit).fill(0); + let numConsecutive = 0; - let currNumber = 10; - while (numConsecutive < targetConsecutive) { - if (NUMFACTORS[currNumber] === targetNumPrimes) + for (let i = 2; i < primeLimit; i++) { + if (numFactors[i] === targetNumPrimes) { + // Current number is composite with target num factors numConsecutive++; - else + if (numConsecutive === targetConsecutive) { + return i - numConsecutive + 1; + } + } else { + // Current number is not matching composite numConsecutive = 0; - currNumber++; + if (numFactors[i] === 0) { + // Current number is prime + for (let j = i; j < primeLimit; j += i) { + numFactors[j]++; + } + } + } } - return currNumber - targetConsecutive; } ``` diff --git a/curriculum/challenges/espanol/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md b/curriculum/challenges/espanol/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md index 861a3e99a8e..7cd5bc67b14 100644 --- a/curriculum/challenges/espanol/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md +++ b/curriculum/challenges/espanol/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md @@ -54,40 +54,56 @@ consecutivePrimeSum(1000000); # --solutions-- ```js -// Initalize prime number list with sieve -const NUM_PRIMES = 1000000; -const PRIMES = [2]; -const PRIME_SIEVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SIEVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - PRIMES.push(prime); - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) - PRIME_SIEVE[j] = false; - } - } - for (let i = sqrtUpper + 1; i < upper; i++) { - if (PRIME_SIEVE[i]) - PRIMES.push(2 * i + 3); - } -})(NUM_PRIMES); +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const primes = [2]; + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); -function isPrime(num) { - if (num === 2) - return true; - else if (num % 2 === 0) - return false - else - return PRIME_SIEVE[(num - 3) / 2]; -} + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + primes.push(prime); + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } + } + } + for (let i = sqrtUpper + 1; i < upper; i++) { + if (seive[i]) { + primes.push(2 * i + 3); + } + } + + this._seive = seive; + this._primes = primes; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } + + get primes() { + return this._primes; + } +}; function consecutivePrimeSum(limit) { + // Initalize seive + const primeSeive = new PrimeSeive(limit); + // Initalize for longest sum < 100 let bestPrime = 41; let bestI = 0; @@ -102,20 +118,20 @@ function consecutivePrimeSum(limit) { // -- Loop while pushing j towards end of PRIMES list // keeping sum under limit while (currSum < limit) { - if (isPrime(currSum)) { + if (primeSeive.isPrime(currSum)) { bestPrime = sumOfCurrRange = currSum; bestI = i; bestJ = j; } // -- Increment inner loop j++; - currSum += PRIMES[j]; + currSum += primeSeive.primes[j]; } // -- Increment outer loop i++; j = i + (bestJ - bestI); - sumOfCurrRange -= PRIMES[i - 1]; - sumOfCurrRange += PRIMES[j]; + sumOfCurrRange -= primeSeive.primes[i - 1]; + sumOfCurrRange += primeSeive.primes[j]; } // Return return bestPrime; diff --git a/curriculum/challenges/espanol/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md b/curriculum/challenges/espanol/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md index 26aed0ce89a..cdbfc3e568b 100644 --- a/curriculum/challenges/espanol/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md +++ b/curriculum/challenges/espanol/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md @@ -56,31 +56,43 @@ primeDigitReplacements(6); # --solutions-- ```js -const NUM_PRIMES = 1000000; -const PRIME_SEIVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SEIVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) { - PRIME_SEIVE[j] = false; +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); + + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } } } - } -})(NUM_PRIMES); -function isPrime(num) { - if (num === 2) return true; - else if (num % 2 === 0) return false - else return PRIME_SEIVE[(num - 3) / 2]; -} + this._seive = seive; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } +}; function primeDigitReplacements(n) { + const primeSeive = new PrimeSeive(n * n * n * 2000); + function isNFamily(number, n) { const prime = number.toString(); const lastDigit = prime[prime.length - 1]; @@ -114,12 +126,12 @@ function primeDigitReplacements(n) { function isPartOfFamily(number, prime) { return ( - isPrime(number) && number.toString().length === prime.length + primeSeive.isPrime(number) && number.toString().length === prime.length ); } for (let number = 1; number < 125000; number++) { - if (isPrime(number) && isNFamily(number, n)) { + if (primeSeive.isPrime(number) && isNFamily(number, n)) { return number; } } diff --git a/curriculum/challenges/espanol/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md b/curriculum/challenges/espanol/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md index 4779cf28cd2..d318ce9f169 100644 --- a/curriculum/challenges/espanol/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md +++ b/curriculum/challenges/espanol/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md @@ -119,7 +119,7 @@ const el = document.getElementById('email') assert(!!el && el.required) ``` -Tu `#email` debe ser descendiente de `#survey-form` +Your `#email` should be a descendant of `#survey-form`. ```js const el = document.querySelector('#survey-form #email') diff --git a/curriculum/challenges/espanol/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md b/curriculum/challenges/espanol/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md index 737ee4206b4..e07f55cfbb7 100644 --- a/curriculum/challenges/espanol/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md +++ b/curriculum/challenges/espanol/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md @@ -7,7 +7,7 @@ dashedName: step-22 # --description-- -Create a new variable below the other one called `--building-color2` and give it a value of `#66cc99`. Then set it as the `background-color` of `.bb2`. +Create a new variable below your `--building-color1` variable. Name your new variable `--building-color2` and give it a value of `#66cc99`. Then set it as the `background-color` of `.bb2`. # --hints-- @@ -17,7 +17,7 @@ You should define a new property variable called `--building-color2`. assert.exists(new __helpers.CSSHelp(document).isPropertyUsed('--building-color2')); ``` -You should give `--building-color2` a value of `#66cc99`. +You should give `--building-color2` a value of `#66cc99` within the `.bb1` class. ```js assert.equal(new __helpers.CSSHelp(document).getStyle('.bb1')?.getPropertyValue('--building-color2').trim(), '#66cc99'); diff --git a/curriculum/challenges/espanol/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md b/curriculum/challenges/espanol/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md index 43bcf1156de..98d3fa7cdbf 100644 --- a/curriculum/challenges/espanol/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md +++ b/curriculum/challenges/espanol/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md @@ -51,7 +51,17 @@ Tu nuevo elemento `input` no tiene un atributo `type`. Comprueba que hay un espa assert($('input')[0].hasAttribute('type')); ``` -Tu nuevo elemento `input` debe tener un atributo `type` con el valor `radio`. Probablemente no has añadido el valor o tienes un error tipográfico. Recuerda que los valores de los atributos deben estar entre comillas. +Your new `input` element should have only one `type` attribute. Remove any extras. + +```js +assert($('input')[0] + .getAttributeNames() + .filter(attr => attr === 'type') + .length === 1 +); +``` + +Your new `input` element should have a `type` attribute with the value `radio`. You have either omitted the value or have a typo. Remember that attribute values should be surrounded with quotation marks. ```js assert( @@ -61,20 +71,20 @@ assert( ); ``` -Aunque al atributo `type` del elemento `input` le hayas dado el valor `radio`, se recomienda siempre poner el valor de un atributo entre comillas. +Although you have set the new `input` element's `type` attribute to `radio`, it is recommended to always surround the value of an attribute with quotation marks. ```js assert(!/\<\s*input\s+type\s*=\s*radio/i.test(code)); ``` -El texto `Indoor` debe estar después del `radio` button no antes. +The `radio` button's `Indoor` text should be located after it instead of before it. ```js const radioInputElem = $('input')[0]; assert(!radioInputElem.previousSibling.nodeValue.match(/Indoor/i)); ``` -El texto `Indoor` debe estar inmediatamente a la derecha del `radio` button ningún espacio. Probablemente no has añadido el texto o tienes un error tipográfico. +The text `Indoor` should be located directly to the right of your `radio` button. You have either omitted the text or have a typo. ```js const radioInputElem = $('input')[0]; @@ -125,6 +135,7 @@ assert(

Cat Form

--fcc-editable-region-- + --fcc-editable-region-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md index b898bc888f5..b880186451d 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md @@ -7,7 +7,7 @@ dashedName: step-154 # --description-- -Use the `+=` operator to add `Your [weapon] breaks.` to the end of `text.innerText`, replacing `weapon` with the last item in the `inventory` array. You can get this last item by using `inventory.pop()`, which will remove the last item in the array AND return it so it appears in your string. +Use the `+=` operator to add `Your [weapon] breaks.`, with a space in front of `Your`, to the end of `text.innerText`. Replace `[weapon]` with the last item in the `inventory` array using `inventory.pop()`, which will remove the last item in the array AND return it so it appears in your string. # --hints-- @@ -24,7 +24,7 @@ You should use the `pop` method on the `inventory` array. assert.match(attack.toString(), /inventory\.pop\(\)/); ``` -You should add the string " Your " to `text.innerText`. Remember that spacing matters. +You should add `Your`, with a space before and after it, to `text.innerText`. ```js assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1/); @@ -37,7 +37,7 @@ console.log(attack.toString()); assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1\s*\+\s*inventory\.pop\(\)/); ``` -You should add `breaks.` to the `"Your " + inventory.pop()` string. +You should add `breaks.`, with a space in front of it, to the end of your string. ```js assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1\s*\+\s*inventory\.pop\(\)\s*\+\s*('|")\sbreaks\.\2/); diff --git a/curriculum/challenges/german/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md b/curriculum/challenges/german/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md index 91f30b8c833..b318f6e4ad6 100644 --- a/curriculum/challenges/german/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md +++ b/curriculum/challenges/german/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md @@ -119,7 +119,7 @@ const el = document.getElementById('email') assert(!!el && el.required) ``` -Deine `#email` sollte ein Nachfolger von `#survey-form` sein +Your `#email` should be a descendant of `#survey-form`. ```js const el = document.querySelector('#survey-form #email') diff --git a/curriculum/challenges/german/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md b/curriculum/challenges/german/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md index 58eaa792f0d..2ab00ac1bac 100644 --- a/curriculum/challenges/german/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md +++ b/curriculum/challenges/german/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md @@ -53,7 +53,7 @@ Du solltest die Destrukturierung verwenden, um die Variable `lowToday` zu erstel ```js assert( code.match( - /(var|const|let)\s*{\s*today\s*:\s*{\s*(low\s*:\s*lowToday[^}]*|[^,]*,\s*low\s*:\s*lowToday\s*)}\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g + /(var|const|let)\s*{\s*today\s*:\s*{\s*(low\s*:\s*lowToday[^}]*|[^,]*,\s*low\s*:\s*lowToday\s*)},?\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g ) ); ``` @@ -63,7 +63,7 @@ Du solltest die Destrukturierung verwenden, um die Variable `highToday` zu erste ```js assert( code.match( - /(var|const|let)\s*{\s*today\s*:\s*{\s*(high\s*:\s*highToday[^}]*|[^,]*,\s*high\s*:\s*highToday\s*)}\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g + /(var|const|let)\s*{\s*today\s*:\s*{\s*(high\s*:\s*highToday[^}]*|[^,]*,\s*high\s*:\s*highToday,?\s*)},?\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g ) ); ``` diff --git a/curriculum/challenges/german/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md b/curriculum/challenges/german/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md index 7e8bea5482e..49d59948762 100644 --- a/curriculum/challenges/german/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md +++ b/curriculum/challenges/german/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md @@ -56,46 +56,57 @@ hexagonalTile(10); # --solutions-- ```js -const NUM_PRIMES = 840000; -const PRIME_SEIVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SEIVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) { - PRIME_SEIVE[j] = false; +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); + + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } } } - } -})(NUM_PRIMES); -function isPrime(num) { - if (num === 2) return true; - else if (num % 2 === 0) return false - else return PRIME_SEIVE[(num - 3) / 2]; -} + this._seive = seive; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } +}; function hexagonalTile(tileIndex) { + const primeSeive = new PrimeSeive(tileIndex * 420); let count = 1; let n = 1; let number = 0; while (count < tileIndex) { - if (isPrime(6*n - 1) && - isPrime(6*n + 1) && - isPrime(12*n + 5)) { + if (primeSeive.isPrime(6*n - 1) && + primeSeive.isPrime(6*n + 1) && + primeSeive.isPrime(12*n + 5)) { number = 3*n*n - 3*n + 2; count++; if (count >= tileIndex) break; } - if (isPrime(6*n + 5) && - isPrime(6*n - 1) && - isPrime(12*n - 7) && n != 1) { + if (primeSeive.isPrime(6*n + 5) && + primeSeive.isPrime(6*n - 1) && + primeSeive.isPrime(12*n - 7) && n != 1) { number = 3*n*n + 3*n + 1; count++; } diff --git a/curriculum/challenges/german/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md b/curriculum/challenges/german/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md index 978b7affd9b..3b79403a4ea 100644 --- a/curriculum/challenges/german/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md +++ b/curriculum/challenges/german/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md @@ -67,25 +67,28 @@ distinctPrimeFactors(4, 4); # --solutions-- ```js -// Initalize factor count with seive -const NUMFACTORS = Array(135000).fill(0); -(function initFactors(num) { - for (let i = 2; i < num; i++) - if (NUMFACTORS[i] === 0) - for (let j = i; j < num; j += i) - NUMFACTORS[j]++; -})(135000); - function distinctPrimeFactors(targetNumPrimes, targetConsecutive) { + const primeLimit = targetNumPrimes * targetConsecutive * 10000; + const numFactors = Array(primeLimit).fill(0); + let numConsecutive = 0; - let currNumber = 10; - while (numConsecutive < targetConsecutive) { - if (NUMFACTORS[currNumber] === targetNumPrimes) + for (let i = 2; i < primeLimit; i++) { + if (numFactors[i] === targetNumPrimes) { + // Current number is composite with target num factors numConsecutive++; - else + if (numConsecutive === targetConsecutive) { + return i - numConsecutive + 1; + } + } else { + // Current number is not matching composite numConsecutive = 0; - currNumber++; + if (numFactors[i] === 0) { + // Current number is prime + for (let j = i; j < primeLimit; j += i) { + numFactors[j]++; + } + } + } } - return currNumber - targetConsecutive; } ``` diff --git a/curriculum/challenges/german/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md b/curriculum/challenges/german/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md index 861a3e99a8e..7cd5bc67b14 100644 --- a/curriculum/challenges/german/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md +++ b/curriculum/challenges/german/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md @@ -54,40 +54,56 @@ consecutivePrimeSum(1000000); # --solutions-- ```js -// Initalize prime number list with sieve -const NUM_PRIMES = 1000000; -const PRIMES = [2]; -const PRIME_SIEVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SIEVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - PRIMES.push(prime); - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) - PRIME_SIEVE[j] = false; - } - } - for (let i = sqrtUpper + 1; i < upper; i++) { - if (PRIME_SIEVE[i]) - PRIMES.push(2 * i + 3); - } -})(NUM_PRIMES); +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const primes = [2]; + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); -function isPrime(num) { - if (num === 2) - return true; - else if (num % 2 === 0) - return false - else - return PRIME_SIEVE[(num - 3) / 2]; -} + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + primes.push(prime); + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } + } + } + for (let i = sqrtUpper + 1; i < upper; i++) { + if (seive[i]) { + primes.push(2 * i + 3); + } + } + + this._seive = seive; + this._primes = primes; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } + + get primes() { + return this._primes; + } +}; function consecutivePrimeSum(limit) { + // Initalize seive + const primeSeive = new PrimeSeive(limit); + // Initalize for longest sum < 100 let bestPrime = 41; let bestI = 0; @@ -102,20 +118,20 @@ function consecutivePrimeSum(limit) { // -- Loop while pushing j towards end of PRIMES list // keeping sum under limit while (currSum < limit) { - if (isPrime(currSum)) { + if (primeSeive.isPrime(currSum)) { bestPrime = sumOfCurrRange = currSum; bestI = i; bestJ = j; } // -- Increment inner loop j++; - currSum += PRIMES[j]; + currSum += primeSeive.primes[j]; } // -- Increment outer loop i++; j = i + (bestJ - bestI); - sumOfCurrRange -= PRIMES[i - 1]; - sumOfCurrRange += PRIMES[j]; + sumOfCurrRange -= primeSeive.primes[i - 1]; + sumOfCurrRange += primeSeive.primes[j]; } // Return return bestPrime; diff --git a/curriculum/challenges/german/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md b/curriculum/challenges/german/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md index 26aed0ce89a..cdbfc3e568b 100644 --- a/curriculum/challenges/german/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md +++ b/curriculum/challenges/german/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md @@ -56,31 +56,43 @@ primeDigitReplacements(6); # --solutions-- ```js -const NUM_PRIMES = 1000000; -const PRIME_SEIVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SEIVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) { - PRIME_SEIVE[j] = false; +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); + + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } } } - } -})(NUM_PRIMES); -function isPrime(num) { - if (num === 2) return true; - else if (num % 2 === 0) return false - else return PRIME_SEIVE[(num - 3) / 2]; -} + this._seive = seive; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } +}; function primeDigitReplacements(n) { + const primeSeive = new PrimeSeive(n * n * n * 2000); + function isNFamily(number, n) { const prime = number.toString(); const lastDigit = prime[prime.length - 1]; @@ -114,12 +126,12 @@ function primeDigitReplacements(n) { function isPartOfFamily(number, prime) { return ( - isPrime(number) && number.toString().length === prime.length + primeSeive.isPrime(number) && number.toString().length === prime.length ); } for (let number = 1; number < 125000; number++) { - if (isPrime(number) && isNFamily(number, n)) { + if (primeSeive.isPrime(number) && isNFamily(number, n)) { return number; } } diff --git a/curriculum/challenges/german/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md b/curriculum/challenges/german/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md index ac8808d9bc6..0e27aa88b20 100644 --- a/curriculum/challenges/german/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md +++ b/curriculum/challenges/german/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md @@ -119,7 +119,7 @@ const el = document.getElementById('email') assert(!!el && el.required) ``` -Your `#email` should be a descendant of `#survey-form` +Your `#email` should be a descendant of `#survey-form`. ```js const el = document.querySelector('#survey-form #email') diff --git a/curriculum/challenges/german/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md b/curriculum/challenges/german/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md index 18d57898d59..af393703a46 100644 --- a/curriculum/challenges/german/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md +++ b/curriculum/challenges/german/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md @@ -7,7 +7,7 @@ dashedName: step-22 # --description-- -Create a new variable below the other one called `--building-color2` and give it a value of `#66cc99`. Then set it as the `background-color` of `.bb2`. +Create a new variable below your `--building-color1` variable. Name your new variable `--building-color2` and give it a value of `#66cc99`. Then set it as the `background-color` of `.bb2`. # --hints-- @@ -17,7 +17,7 @@ You should define a new property variable called `--building-color2`. assert.exists(new __helpers.CSSHelp(document).isPropertyUsed('--building-color2')); ``` -You should give `--building-color2` a value of `#66cc99`. +You should give `--building-color2` a value of `#66cc99` within the `.bb1` class. ```js assert.equal(new __helpers.CSSHelp(document).getStyle('.bb1')?.getPropertyValue('--building-color2').trim(), '#66cc99'); diff --git a/curriculum/challenges/german/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md b/curriculum/challenges/german/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md index 8807e7121c8..7792d99d5e8 100644 --- a/curriculum/challenges/german/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md +++ b/curriculum/challenges/german/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md @@ -51,6 +51,16 @@ Your new `input` element does not have a `type` attribute. Check that there is a assert($('input')[0].hasAttribute('type')); ``` +Your new `input` element should have only one `type` attribute. Remove any extras. + +```js +assert($('input')[0] + .getAttributeNames() + .filter(attr => attr === 'type') + .length === 1 +); +``` + Your new `input` element should have a `type` attribute with the value `radio`. You have either omitted the value or have a typo. Remember that attribute values should be surrounded with quotation marks. ```js @@ -125,6 +135,7 @@ assert(

Cat Form

--fcc-editable-region-- + --fcc-editable-region-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md index 02ffeb838f6..bb4bb752806 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md @@ -7,7 +7,7 @@ dashedName: step-154 # --description-- -Use the `+=` operator to add `Your [weapon] breaks.` to the end of `text.innerText`, replacing `weapon` with the last item in the `inventory` array. You can get this last item by using `inventory.pop()`, which will remove the last item in the array AND return it so it appears in your string. +Use the `+=` operator to add `Your [weapon] breaks.`, with a space in front of `Your`, to the end of `text.innerText`. Replace `[weapon]` with the last item in the `inventory` array using `inventory.pop()`, which will remove the last item in the array AND return it so it appears in your string. # --hints-- @@ -24,7 +24,7 @@ You should use the `pop` method on the `inventory` array. assert.match(attack.toString(), /inventory\.pop\(\)/); ``` -You should add the string " Your " to `text.innerText`. Remember that spacing matters. +You should add `Your`, with a space before and after it, to `text.innerText`. ```js assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1/); @@ -37,7 +37,7 @@ console.log(attack.toString()); assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1\s*\+\s*inventory\.pop\(\)/); ``` -You should add `breaks.` to the `"Your " + inventory.pop()` string. +You should add `breaks.`, with a space in front of it, to the end of your string. ```js assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1\s*\+\s*inventory\.pop\(\)\s*\+\s*('|")\sbreaks\.\2/); diff --git a/curriculum/challenges/italian/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md b/curriculum/challenges/italian/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md index 906cb52f587..4ff49ba5974 100644 --- a/curriculum/challenges/italian/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md +++ b/curriculum/challenges/italian/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md @@ -119,7 +119,7 @@ const el = document.getElementById('email') assert(!!el && el.required) ``` -L'elemento `#email` dovrebbe essere un discendente di `#survey-form` +Your `#email` should be a descendant of `#survey-form`. ```js const el = document.querySelector('#survey-form #email') diff --git a/curriculum/challenges/italian/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md b/curriculum/challenges/italian/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md index 0bd4fd11032..3aa8e054ac0 100644 --- a/curriculum/challenges/italian/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md +++ b/curriculum/challenges/italian/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md @@ -53,7 +53,7 @@ Dovresti usare la destrutturazione per creare la variabile `lowToday`. ```js assert( code.match( - /(var|const|let)\s*{\s*today\s*:\s*{\s*(low\s*:\s*lowToday[^}]*|[^,]*,\s*low\s*:\s*lowToday\s*)}\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g + /(var|const|let)\s*{\s*today\s*:\s*{\s*(low\s*:\s*lowToday[^}]*|[^,]*,\s*low\s*:\s*lowToday\s*)},?\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g ) ); ``` @@ -63,7 +63,7 @@ Dovresti usare la destrutturazione per creare la variabile `highToday`. ```js assert( code.match( - /(var|const|let)\s*{\s*today\s*:\s*{\s*(high\s*:\s*highToday[^}]*|[^,]*,\s*high\s*:\s*highToday\s*)}\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g + /(var|const|let)\s*{\s*today\s*:\s*{\s*(high\s*:\s*highToday[^}]*|[^,]*,\s*high\s*:\s*highToday,?\s*)},?\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g ) ); ``` diff --git a/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-125-palindromic-sums.md b/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-125-palindromic-sums.md index 67eda16947c..f44bfe9f7b4 100644 --- a/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-125-palindromic-sums.md +++ b/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-125-palindromic-sums.md @@ -12,10 +12,10 @@ Il numero palindromo 595 è interessante perché può essere scritto come la som Ci sono esattamente undici palindromi sotto il mille che possono essere scritti come somma di quadrati consecutivi, e la somma di questi palindromi è 4164. Nota che $1 = 0^2 + 1^2$ non è stato incluso in quanto questo problema riguarda i quadrati degli interi positivi. -Find the sum of all the numbers less than the `limit` that are both palindromic and can be written as the sum of consecutive squares. +Trova la somma di tutti i numeri inferiori a `limit` che allo stesso tempo sono palindromi e possono essere scritti come la somma di quadrati consecutivi. # --hints-- -`palindromicSums(100000000)` should return `2906969179`. +`palindromicSums(100000000)` dovrebbe restituire `2906969179`. ```js @@ -23,13 +23,13 @@ assert.strictEqual(palindromicSums(100000000), 2906969179); ``` -`palindromicSums(100)` should return `137`. +`palindromicSums(100)` dovrebbe restituire `137`. ```js assert.strictEqual(palindromicSums(100), 137); ``` -`palindromicSums(1000)` should return `4164`. +`palindromicSums(1000)` dovrebbe restituire `4164`. ```js assert.strictEqual(palindromicSums(1000),4164); diff --git a/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md b/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md index 4fb9122b2ef..41740bb4c15 100644 --- a/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md +++ b/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md @@ -56,46 +56,57 @@ hexagonalTile(10); # --solutions-- ```js -const NUM_PRIMES = 840000; -const PRIME_SEIVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SEIVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) { - PRIME_SEIVE[j] = false; +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); + + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } } } - } -})(NUM_PRIMES); -function isPrime(num) { - if (num === 2) return true; - else if (num % 2 === 0) return false - else return PRIME_SEIVE[(num - 3) / 2]; -} + this._seive = seive; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } +}; function hexagonalTile(tileIndex) { + const primeSeive = new PrimeSeive(tileIndex * 420); let count = 1; let n = 1; let number = 0; while (count < tileIndex) { - if (isPrime(6*n - 1) && - isPrime(6*n + 1) && - isPrime(12*n + 5)) { + if (primeSeive.isPrime(6*n - 1) && + primeSeive.isPrime(6*n + 1) && + primeSeive.isPrime(12*n + 5)) { number = 3*n*n - 3*n + 2; count++; if (count >= tileIndex) break; } - if (isPrime(6*n + 5) && - isPrime(6*n - 1) && - isPrime(12*n - 7) && n != 1) { + if (primeSeive.isPrime(6*n + 5) && + primeSeive.isPrime(6*n - 1) && + primeSeive.isPrime(12*n - 7) && n != 1) { number = 3*n*n + 3*n + 1; count++; } diff --git a/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md b/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md index 8de7c33f077..cac0d8c2560 100644 --- a/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md +++ b/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md @@ -67,25 +67,28 @@ distinctPrimeFactors(4, 4); # --solutions-- ```js -// Initalize factor count with seive -const NUMFACTORS = Array(135000).fill(0); -(function initFactors(num) { - for (let i = 2; i < num; i++) - if (NUMFACTORS[i] === 0) - for (let j = i; j < num; j += i) - NUMFACTORS[j]++; -})(135000); - function distinctPrimeFactors(targetNumPrimes, targetConsecutive) { + const primeLimit = targetNumPrimes * targetConsecutive * 10000; + const numFactors = Array(primeLimit).fill(0); + let numConsecutive = 0; - let currNumber = 10; - while (numConsecutive < targetConsecutive) { - if (NUMFACTORS[currNumber] === targetNumPrimes) + for (let i = 2; i < primeLimit; i++) { + if (numFactors[i] === targetNumPrimes) { + // Current number is composite with target num factors numConsecutive++; - else + if (numConsecutive === targetConsecutive) { + return i - numConsecutive + 1; + } + } else { + // Current number is not matching composite numConsecutive = 0; - currNumber++; + if (numFactors[i] === 0) { + // Current number is prime + for (let j = i; j < primeLimit; j += i) { + numFactors[j]++; + } + } + } } - return currNumber - targetConsecutive; } ``` diff --git a/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md b/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md index be2764f49c8..9d27b39aaf6 100644 --- a/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md +++ b/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md @@ -54,40 +54,56 @@ consecutivePrimeSum(1000000); # --solutions-- ```js -// Initalize prime number list with sieve -const NUM_PRIMES = 1000000; -const PRIMES = [2]; -const PRIME_SIEVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SIEVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - PRIMES.push(prime); - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) - PRIME_SIEVE[j] = false; - } - } - for (let i = sqrtUpper + 1; i < upper; i++) { - if (PRIME_SIEVE[i]) - PRIMES.push(2 * i + 3); - } -})(NUM_PRIMES); +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const primes = [2]; + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); -function isPrime(num) { - if (num === 2) - return true; - else if (num % 2 === 0) - return false - else - return PRIME_SIEVE[(num - 3) / 2]; -} + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + primes.push(prime); + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } + } + } + for (let i = sqrtUpper + 1; i < upper; i++) { + if (seive[i]) { + primes.push(2 * i + 3); + } + } + + this._seive = seive; + this._primes = primes; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } + + get primes() { + return this._primes; + } +}; function consecutivePrimeSum(limit) { + // Initalize seive + const primeSeive = new PrimeSeive(limit); + // Initalize for longest sum < 100 let bestPrime = 41; let bestI = 0; @@ -102,20 +118,20 @@ function consecutivePrimeSum(limit) { // -- Loop while pushing j towards end of PRIMES list // keeping sum under limit while (currSum < limit) { - if (isPrime(currSum)) { + if (primeSeive.isPrime(currSum)) { bestPrime = sumOfCurrRange = currSum; bestI = i; bestJ = j; } // -- Increment inner loop j++; - currSum += PRIMES[j]; + currSum += primeSeive.primes[j]; } // -- Increment outer loop i++; j = i + (bestJ - bestI); - sumOfCurrRange -= PRIMES[i - 1]; - sumOfCurrRange += PRIMES[j]; + sumOfCurrRange -= primeSeive.primes[i - 1]; + sumOfCurrRange += primeSeive.primes[j]; } // Return return bestPrime; diff --git a/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md b/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md index ed2906261f1..e0f876e1e60 100644 --- a/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md +++ b/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md @@ -56,31 +56,43 @@ primeDigitReplacements(6); # --solutions-- ```js -const NUM_PRIMES = 1000000; -const PRIME_SEIVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SEIVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) { - PRIME_SEIVE[j] = false; +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); + + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } } } - } -})(NUM_PRIMES); -function isPrime(num) { - if (num === 2) return true; - else if (num % 2 === 0) return false - else return PRIME_SEIVE[(num - 3) / 2]; -} + this._seive = seive; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } +}; function primeDigitReplacements(n) { + const primeSeive = new PrimeSeive(n * n * n * 2000); + function isNFamily(number, n) { const prime = number.toString(); const lastDigit = prime[prime.length - 1]; @@ -114,12 +126,12 @@ function primeDigitReplacements(n) { function isPartOfFamily(number, prime) { return ( - isPrime(number) && number.toString().length === prime.length + primeSeive.isPrime(number) && number.toString().length === prime.length ); } for (let number = 1; number < 125000; number++) { - if (isPrime(number) && isNFamily(number, n)) { + if (primeSeive.isPrime(number) && isNFamily(number, n)) { return number; } } diff --git a/curriculum/challenges/italian/10-coding-interview-prep/rosetta-code/state-name-puzzle.md b/curriculum/challenges/italian/10-coding-interview-prep/rosetta-code/state-name-puzzle.md index 6eb9fec20e4..a9e2dbb1329 100644 --- a/curriculum/challenges/italian/10-coding-interview-prep/rosetta-code/state-name-puzzle.md +++ b/curriculum/challenges/italian/10-coding-interview-prep/rosetta-code/state-name-puzzle.md @@ -15,7 +15,7 @@ dashedName: state-name-puzzle Scrivi una funzione per risolvere la sfida per un dato array di veri nomi di stati americani, e per nomi di stati fittizi. -La funzione dovrebbe restituire un array. Ogni elemento deve essere un oggetto in questa forma: `{"from":[],"to":[]}`. The `from` array should contain the original names and the `to` array should contain the resultant names. +La funzione dovrebbe restituire un array. Ogni elemento deve essere un oggetto in questa forma: `{"from":[],"to":[]}`. L'array `from` dovrebbe contenere i nomi originali e l'array `to` dovrebbe contenere i nomi risultanti. # --hints-- diff --git a/curriculum/challenges/italian/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md b/curriculum/challenges/italian/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md index fed0080170e..a5b3f954136 100644 --- a/curriculum/challenges/italian/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md +++ b/curriculum/challenges/italian/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md @@ -119,7 +119,7 @@ const el = document.getElementById('email') assert(!!el && el.required) ``` -L'elemento `#email` dovrebbe essere un discendente di `#survey-form` +Your `#email` should be a descendant of `#survey-form`. ```js const el = document.querySelector('#survey-form #email') diff --git a/curriculum/challenges/italian/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md b/curriculum/challenges/italian/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md index b1be4ade5d9..3b253034005 100644 --- a/curriculum/challenges/italian/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md +++ b/curriculum/challenges/italian/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md @@ -7,7 +7,7 @@ dashedName: step-22 # --description-- -Crea una nuova variabile sotto l'altra, chiamala `--building-color2` e dalle il valore `#66cc99`. Quindi impostala come valore `background-color` di `.bb2`. +Create a new variable below your `--building-color1` variable. Name your new variable `--building-color2` and give it a value of `#66cc99`. Then set it as the `background-color` of `.bb2`. # --hints-- @@ -17,7 +17,7 @@ Dovresti definire una nuova variabile di proprietà chiamata `--building-color2` assert.exists(new __helpers.CSSHelp(document).isPropertyUsed('--building-color2')); ``` -Dovresti dare a `--building-color2` il valore `#66cc99`. +You should give `--building-color2` a value of `#66cc99` within the `.bb1` class. ```js assert.equal(new __helpers.CSSHelp(document).getStyle('.bb1')?.getPropertyValue('--building-color2').trim(), '#66cc99'); diff --git a/curriculum/challenges/italian/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md b/curriculum/challenges/italian/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md index 92b4cc58e44..899f82b6b4c 100644 --- a/curriculum/challenges/italian/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md +++ b/curriculum/challenges/italian/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md @@ -51,7 +51,17 @@ Il nuovo elemento `input` non ha un attributo `type`. Controlla che ci sia uno s assert($('input')[0].hasAttribute('type')); ``` -Il nuovo elemento `input` dovrebbe avere un attributo `type` con il valore `radio`. Hai omesso il valore o hai un refuso. Ricorda che i valori degli attributi devono essere racchiusi tra virgolette. +Your new `input` element should have only one `type` attribute. Remove any extras. + +```js +assert($('input')[0] + .getAttributeNames() + .filter(attr => attr === 'type') + .length === 1 +); +``` + +Your new `input` element should have a `type` attribute with the value `radio`. You have either omitted the value or have a typo. Remember that attribute values should be surrounded with quotation marks. ```js assert( @@ -61,20 +71,20 @@ assert( ); ``` -Sebbene tu abbia impostato `radio` come valore dell'attributo `type` del nuovo elemento `input`, è raccomandato inserire sempre il valore di un attributo tra virgolette. +Although you have set the new `input` element's `type` attribute to `radio`, it is recommended to always surround the value of an attribute with quotation marks. ```js assert(!/\<\s*input\s+type\s*=\s*radio/i.test(code)); ``` -Il testo `Indoor` del pulsante di opzione dovrebbe essere posizionato dopo di esso invece che prima. +The `radio` button's `Indoor` text should be located after it instead of before it. ```js const radioInputElem = $('input')[0]; assert(!radioInputElem.previousSibling.nodeValue.match(/Indoor/i)); ``` -Il testo `Indoor` dovrebbe essere posizionato direttamente a destra del pulsante di opzione. Hai omesso il testo o hai un refuso. +The text `Indoor` should be located directly to the right of your `radio` button. You have either omitted the text or have a typo. ```js const radioInputElem = $('input')[0]; @@ -125,6 +135,7 @@ assert(

Cat Form

--fcc-editable-region-- + --fcc-editable-region-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md index a38c8054764..31fe4193ad4 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md @@ -7,7 +7,7 @@ dashedName: step-154 # --description-- -Usa l'operatore `+=` per aggiungere `Your [weapon] breaks.` alla fine di `text.innerText`, sostituendo `weapon` con l'ultimo elemento nell'array `inventory`. Puoi ottenere l'ultimo elemento con `inventory.pop()`, che rimuove l'ultimo elemento nell'array E lo restituisce, così che appaia nella stringa. +Use the `+=` operator to add `Your [weapon] breaks.`, with a space in front of `Your`, to the end of `text.innerText`. Replace `[weapon]` with the last item in the `inventory` array using `inventory.pop()`, which will remove the last item in the array AND return it so it appears in your string. # --hints-- @@ -24,7 +24,7 @@ Dovresti usare il metodo `pop` sull'array `inventory`. assert.match(attack.toString(), /inventory\.pop\(\)/); ``` -Dovresti aggiungere la stringa " Your " a `text.innerText`. Ricorda che la spaziatura è importante. +You should add `Your`, with a space before and after it, to `text.innerText`. ```js assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1/); @@ -37,7 +37,7 @@ console.log(attack.toString()); assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1\s*\+\s*inventory\.pop\(\)/); ``` -Dovresti aggiungere `breaks.` alla stringa `"Your " + inventory.pop()`. +You should add `breaks.`, with a space in front of it, to the end of your string. ```js assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1\s*\+\s*inventory\.pop\(\)\s*\+\s*('|")\sbreaks\.\2/); diff --git a/curriculum/challenges/japanese/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md b/curriculum/challenges/japanese/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md index cbef61b930f..f7615d0177d 100644 --- a/curriculum/challenges/japanese/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md +++ b/curriculum/challenges/japanese/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md @@ -119,7 +119,7 @@ const el = document.getElementById('email') assert(!!el && el.required) ``` -`#email` は `#survey-form` の子孫要素である必要があります +Your `#email` should be a descendant of `#survey-form`. ```js const el = document.querySelector('#survey-form #email') diff --git a/curriculum/challenges/japanese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md b/curriculum/challenges/japanese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md index ef7d3a96c88..e9633c3535f 100644 --- a/curriculum/challenges/japanese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md +++ b/curriculum/challenges/japanese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md @@ -53,7 +53,7 @@ assert( ```js assert( code.match( - /(var|const|let)\s*{\s*today\s*:\s*{\s*(low\s*:\s*lowToday[^}]*|[^,]*,\s*low\s*:\s*lowToday\s*)}\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g + /(var|const|let)\s*{\s*today\s*:\s*{\s*(low\s*:\s*lowToday[^}]*|[^,]*,\s*low\s*:\s*lowToday\s*)},?\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g ) ); ``` @@ -63,7 +63,7 @@ assert( ```js assert( code.match( - /(var|const|let)\s*{\s*today\s*:\s*{\s*(high\s*:\s*highToday[^}]*|[^,]*,\s*high\s*:\s*highToday\s*)}\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g + /(var|const|let)\s*{\s*today\s*:\s*{\s*(high\s*:\s*highToday[^}]*|[^,]*,\s*high\s*:\s*highToday,?\s*)},?\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g ) ); ``` diff --git a/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md b/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md index 7b1bff7fa2b..7751c70381b 100644 --- a/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md +++ b/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md @@ -56,46 +56,57 @@ hexagonalTile(10); # --solutions-- ```js -const NUM_PRIMES = 840000; -const PRIME_SEIVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SEIVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) { - PRIME_SEIVE[j] = false; +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); + + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } } } - } -})(NUM_PRIMES); -function isPrime(num) { - if (num === 2) return true; - else if (num % 2 === 0) return false - else return PRIME_SEIVE[(num - 3) / 2]; -} + this._seive = seive; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } +}; function hexagonalTile(tileIndex) { + const primeSeive = new PrimeSeive(tileIndex * 420); let count = 1; let n = 1; let number = 0; while (count < tileIndex) { - if (isPrime(6*n - 1) && - isPrime(6*n + 1) && - isPrime(12*n + 5)) { + if (primeSeive.isPrime(6*n - 1) && + primeSeive.isPrime(6*n + 1) && + primeSeive.isPrime(12*n + 5)) { number = 3*n*n - 3*n + 2; count++; if (count >= tileIndex) break; } - if (isPrime(6*n + 5) && - isPrime(6*n - 1) && - isPrime(12*n - 7) && n != 1) { + if (primeSeive.isPrime(6*n + 5) && + primeSeive.isPrime(6*n - 1) && + primeSeive.isPrime(12*n - 7) && n != 1) { number = 3*n*n + 3*n + 1; count++; } diff --git a/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md b/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md index 02c5136b705..bb14209cd5b 100644 --- a/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md +++ b/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md @@ -67,25 +67,28 @@ distinctPrimeFactors(4, 4); # --solutions-- ```js -// Initalize factor count with seive -const NUMFACTORS = Array(135000).fill(0); -(function initFactors(num) { - for (let i = 2; i < num; i++) - if (NUMFACTORS[i] === 0) - for (let j = i; j < num; j += i) - NUMFACTORS[j]++; -})(135000); - function distinctPrimeFactors(targetNumPrimes, targetConsecutive) { + const primeLimit = targetNumPrimes * targetConsecutive * 10000; + const numFactors = Array(primeLimit).fill(0); + let numConsecutive = 0; - let currNumber = 10; - while (numConsecutive < targetConsecutive) { - if (NUMFACTORS[currNumber] === targetNumPrimes) + for (let i = 2; i < primeLimit; i++) { + if (numFactors[i] === targetNumPrimes) { + // Current number is composite with target num factors numConsecutive++; - else + if (numConsecutive === targetConsecutive) { + return i - numConsecutive + 1; + } + } else { + // Current number is not matching composite numConsecutive = 0; - currNumber++; + if (numFactors[i] === 0) { + // Current number is prime + for (let j = i; j < primeLimit; j += i) { + numFactors[j]++; + } + } + } } - return currNumber - targetConsecutive; } ``` diff --git a/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md b/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md index 9c3909af21a..3194e056368 100644 --- a/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md +++ b/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md @@ -54,40 +54,56 @@ consecutivePrimeSum(1000000); # --solutions-- ```js -// Initalize prime number list with sieve -const NUM_PRIMES = 1000000; -const PRIMES = [2]; -const PRIME_SIEVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SIEVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - PRIMES.push(prime); - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) - PRIME_SIEVE[j] = false; - } - } - for (let i = sqrtUpper + 1; i < upper; i++) { - if (PRIME_SIEVE[i]) - PRIMES.push(2 * i + 3); - } -})(NUM_PRIMES); +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const primes = [2]; + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); -function isPrime(num) { - if (num === 2) - return true; - else if (num % 2 === 0) - return false - else - return PRIME_SIEVE[(num - 3) / 2]; -} + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + primes.push(prime); + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } + } + } + for (let i = sqrtUpper + 1; i < upper; i++) { + if (seive[i]) { + primes.push(2 * i + 3); + } + } + + this._seive = seive; + this._primes = primes; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } + + get primes() { + return this._primes; + } +}; function consecutivePrimeSum(limit) { + // Initalize seive + const primeSeive = new PrimeSeive(limit); + // Initalize for longest sum < 100 let bestPrime = 41; let bestI = 0; @@ -102,20 +118,20 @@ function consecutivePrimeSum(limit) { // -- Loop while pushing j towards end of PRIMES list // keeping sum under limit while (currSum < limit) { - if (isPrime(currSum)) { + if (primeSeive.isPrime(currSum)) { bestPrime = sumOfCurrRange = currSum; bestI = i; bestJ = j; } // -- Increment inner loop j++; - currSum += PRIMES[j]; + currSum += primeSeive.primes[j]; } // -- Increment outer loop i++; j = i + (bestJ - bestI); - sumOfCurrRange -= PRIMES[i - 1]; - sumOfCurrRange += PRIMES[j]; + sumOfCurrRange -= primeSeive.primes[i - 1]; + sumOfCurrRange += primeSeive.primes[j]; } // Return return bestPrime; diff --git a/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md b/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md index 6fa3d72a2ac..03c5a581301 100644 --- a/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md +++ b/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md @@ -56,31 +56,43 @@ primeDigitReplacements(6); # --solutions-- ```js -const NUM_PRIMES = 1000000; -const PRIME_SEIVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SEIVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) { - PRIME_SEIVE[j] = false; +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); + + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } } } - } -})(NUM_PRIMES); -function isPrime(num) { - if (num === 2) return true; - else if (num % 2 === 0) return false - else return PRIME_SEIVE[(num - 3) / 2]; -} + this._seive = seive; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } +}; function primeDigitReplacements(n) { + const primeSeive = new PrimeSeive(n * n * n * 2000); + function isNFamily(number, n) { const prime = number.toString(); const lastDigit = prime[prime.length - 1]; @@ -114,12 +126,12 @@ function primeDigitReplacements(n) { function isPartOfFamily(number, prime) { return ( - isPrime(number) && number.toString().length === prime.length + primeSeive.isPrime(number) && number.toString().length === prime.length ); } for (let number = 1; number < 125000; number++) { - if (isPrime(number) && isNFamily(number, n)) { + if (primeSeive.isPrime(number) && isNFamily(number, n)) { return number; } } diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md b/curriculum/challenges/japanese/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md index ce39c53575e..a8d274d1282 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md @@ -91,7 +91,7 @@ const el = document.getElementById('name') assert(!!el && el.required) ``` -Your `#name` should be a descendant of `#survey-form`. +`#name` は `#survey-form` の子孫要素である必要があります。 ```js const el = document.querySelector('#survey-form #name') @@ -119,7 +119,7 @@ const el = document.getElementById('email') assert(!!el && el.required) ``` -Your `#email` should be a descendant of `#survey-form` +Your `#email` should be a descendant of `#survey-form`. ```js const el = document.querySelector('#survey-form #email') @@ -133,7 +133,7 @@ const el = document.getElementById('number') assert(!!el && el.tagName === 'INPUT') ``` -Your `#number` should be a descendant of `#survey-form`. +`#number` は `#survey-form` の子孫要素である必要があります。 ```js const el = document.querySelector('#survey-form #number') @@ -203,21 +203,21 @@ const el = document.getElementById('number-label') assert(!!el && el.innerText.length > 0) ``` -Your `#name-label` should be a descendant of `#survey-form`. +`#name-label` は `#survey-form` の子孫要素である必要があります。 ```js const el = document.querySelector('#survey-form #name-label') assert(!!el) ``` -Your `#email-label` should be a descendant of `#survey-form`. +`#email-label` は `#survey-form` の子孫要素である必要があります。 ```js const el = document.querySelector('#survey-form #email-label') assert(!!el) ``` -Your `#number-label` should be a descendant of `#survey-form`. +`#number-label` は `#survey-form` の子孫要素である必要があります。 ```js const el = document.querySelector('#survey-form #number-label') diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-accessibility-by-building-a-quiz/6148da157cc0bd0d06df5c0a.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-accessibility-by-building-a-quiz/6148da157cc0bd0d06df5c0a.md index 10f43b5fe50..6c846615a5f 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-accessibility-by-building-a-quiz/6148da157cc0bd0d06df5c0a.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-accessibility-by-building-a-quiz/6148da157cc0bd0d06df5c0a.md @@ -7,9 +7,9 @@ dashedName: step-56 # --description-- -`input` ボックスの位置を揃えるため、`.info` 要素内のすべての `input` と `label` 要素を対象に、`display` プロパティを `inline-block` に設定してください。 +`input` ボックスの位置を揃えるために、`.info` 要素内の `input` 要素と `label` 要素すべての `display` プロパティを `inline-block` に設定してください。 -Also, align the `label` element's text to the right. +また、`label` 要素のテキストを右側に揃えてください。 # --hints-- @@ -28,7 +28,7 @@ const display = gs('.info > label, .info > input') ?? gs('.info label, .info inp assert.equal(display, 'inline-block'); ``` -You should give the `label` element a `text-align` of `right`. +`label` 要素の `text-align` を `right` に設定する必要があります。 ```js const gs = (s) => new __helpers.CSSHelp(document).getStyle(s)?.textAlign; diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-grid-by-building-a-magazine/61437d575fb98f57fa8f7f36.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-grid-by-building-a-magazine/61437d575fb98f57fa8f7f36.md index 66f2ee1b703..3c9d8f839c3 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-grid-by-building-a-magazine/61437d575fb98f57fa8f7f36.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-grid-by-building-a-magazine/61437d575fb98f57fa8f7f36.md @@ -7,19 +7,19 @@ dashedName: step-1 # --description-- -Begin with your standard HTML boilerplate. Add a `DOCTYPE` declaration, an `html` element specifying this page is in English, a `head` element, and a `body` element. +標準的な HTML ボイラープレートから始めましょう。 `DOCTYPE` 宣言と、このページが英語であることを指定する `html` 要素、`head` 要素 および `body` 要素を追加してください。 -Add a `` tag with the appropriate `charset` and a `` tag for mobile responsiveness within the `head` element. +`head` 要素内には、適切な `charset` を持つ `` タグと、モバイル対応にするための `` タグを追加してください。 # --hints-- -Your code should contain the `DOCTYPE` reference. +コードに `DOCTYPE` 参照を入れる必要があります。 ```js assert(code.match(//gi)); ``` -You should have an opening `` tag, and it should have `lang` of `en`. +`lang` を `en` に設定した `` の開始タグが必要です。 ```js assert(code.match(//gi)); ``` -Your `html` element should have a closing tag. +`html` 要素には終了タグが必要です。 ```js assert(code.match(/<\/html\s*>/)); ``` -Your `DOCTYPE` declaration should be at the beginning of your HTML. +`DOCTYPE` 宣言は HTML の先頭にある必要があります。 ```js assert(__helpers.removeHtmlComments(code).match(/^\s*/i)); ``` -You should have an opening `` tag. +`` の開始タグが 1 つ必要です。 ```js assert(code.match(//i)); ``` -You should have a closing `` tag. +`` の終了タグが 1 つ必要です。 ```js assert(code.match(/<\/head\s*>/i)); ``` -You should have an opening `` tag. +`` の開始タグが 1 つ必要です。 ```js assert(code.match(//i)); ``` -You should have a closing `` tag. +終了タグ `` が 1 つ必要です。 ```js assert(code.match(/<\/body\s*>/i)); ``` -The `head` and `body` elements should be siblings. +`head` 要素と `body` 要素は兄弟要素である必要があります。 ```js assert(document.querySelector('head')?.nextElementSibling?.localName === 'body'); ``` -The `head` element should be within the `html` element. +`head` 要素は `html` 要素の中にある必要があります。 ```js assert([...document.querySelector('html')?.children].some(x => x?.localName === 'head')); ``` -The `body` element should be within the `html` element. +`body` 要素は `html` 要素の中にある必要があります。 ```js assert([...document.querySelector('html')?.children].some(x => x?.localName === 'body')); ``` -You should have two `meta` elements. +2 つの `meta` 要素が必要です。 ```js const meta = document.querySelectorAll('meta'); assert(meta?.length === 2); ``` -One `meta` element should have a `name` set to `viewport`, and `content` set to `width=device-width, initial-scale=1.0`. +`meta` 要素のひとつは `name` 属性を `viewport` に、`content` 属性を `width=device-width, initial-scale=1.0` に設定されている必要があります。 ```js const meta = [...document.querySelectorAll('meta')]; @@ -112,7 +112,7 @@ const target = meta?.find(m => m?.getAttribute('name') === 'viewport' && m?.getA assert.exists(target); ``` -The other `meta` element should have the `charset` attribute set to `UTF-8`. +もうひとつの `meta` 要素は `charset` 属性を `UTF-8` に設定されている必要があります。 ```js const meta = [...document.querySelectorAll('meta')]; diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98d5.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98d5.md index 8fba23243fe..0a7f67a6b2a 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98d5.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98d5.md @@ -7,7 +7,7 @@ dashedName: step-13 # --description-- -Center the parts of your building by turning the `.bb1` element into a flexbox parent. Use the `flex-direction` and `align-items` properties to center the children. +ビルの各部分を真ん中に寄せるため、`.bb1` 要素をフレックスボックスの親にしましょう。 `flex-direction` と `align-items` のプロパティを使って、子要素を中央揃えにしてください。 # --hints-- diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md index b8de66e15ff..8f01578420d 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md @@ -7,7 +7,7 @@ dashedName: step-22 # --description-- -今ある変数の下に `--building-color2` という新しい変数を作成し、値を `#66cc99` に設定してください。 次にその変数を `.bb2` の `background-color` として設定してみましょう。 +Create a new variable below your `--building-color1` variable. Name your new variable `--building-color2` and give it a value of `#66cc99`. Then set it as the `background-color` of `.bb2`. # --hints-- @@ -17,7 +17,7 @@ dashedName: step-22 assert.exists(new __helpers.CSSHelp(document).isPropertyUsed('--building-color2')); ``` -`--building-color2` に値 `#66cc99` を代入してください。 +You should give `--building-color2` a value of `#66cc99` within the `.bb1` class. ```js assert.equal(new __helpers.CSSHelp(document).getStyle('.bb1')?.getPropertyValue('--building-color2').trim(), '#66cc99'); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98ef.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98ef.md index dbcb22d6132..224e26aaea4 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98ef.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98ef.md @@ -7,7 +7,7 @@ dashedName: step-39 # --description-- -`:root` 内に `--window-color1` という新しい変数を作成し、値を `black` に設定してください。 これは紫色のビルに使う二つめの色になります。 +`:root` 内に `--window-color1` という新しい変数を作成し、値を `black` に設定してください。 これは紫色のビルに使うサブカラーになります。 # --hints-- diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98fa.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98fa.md index 6c1a669610a..527faf400f0 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98fa.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98fa.md @@ -7,7 +7,7 @@ dashedName: step-50 # --description-- -`:root` 内に `window-color2` という新しい変数を作成し、値を `#8cd9b3` に設定してください。 これは、このビルの二つめの色として使います。 +`:root` 内に `window-color2` という新しい変数を作成し、値を `#8cd9b3` に設定してください。 これは、このビルのサブカラーとして使います。 # --hints-- diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9903.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9903.md index 88116920130..7ad07e8b43d 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9903.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9903.md @@ -7,7 +7,7 @@ dashedName: step-59 # --description-- -次のビルに取り掛かりましょう! `--window-color3` という新しい変数を `:root` に作成し、値 `#d98cb3` を設定してください。 これはピンク色のビルに使う二つめの色になります。 +次のビルに取り掛かりましょう! `--window-color3` という新しい変数を `:root` に作成し、値 `#d98cb3` を設定してください。 これはピンク色のビルに使うサブカラーになります。 # --hints-- diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e990c.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e990c.md index 42f403acbb8..4cd7fad9752 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e990c.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e990c.md @@ -7,7 +7,7 @@ dashedName: step-68 # --description-- -`:root` 内に `--window-color4` という新しい変数を作成し、値 `#8cb3d9` を設定してください。 これは奥側の最後のビルに使う二つめの色になります。 +`:root` 内に `--window-color4` という新しい変数を作成し、値 `#8cb3d9` を設定してください。 これは奥側の最後のビルに使うサブカラーになります。 # --hints-- diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9915.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9915.md index f8af0ff75b1..39ab2aa737a 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9915.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9915.md @@ -7,11 +7,11 @@ dashedName: step-106 # --description-- -You don't need the `background-color` for this building anymore so you can remove that property. +このビルの `background-color` プロパティは不要になったので削除しましょう。 # --hints-- -You should remove the `background-color` of `.fb5`. +`.fb5` から `background-color` を削除する必要があります。 ```js assert.notMatch(code, /\.fb5\s*\{\s*[^}]*?background-color[^}]*?\}/); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9929.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9929.md index 4bc1706059d..5325abc51ae 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9929.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9929.md @@ -7,23 +7,23 @@ dashedName: step-96 # --description-- -Only three more buildings to go. Nest two new `div` elements within the `.fb4` element and give them the classes of `fb4a` and `fb4b`, in that order. Remember that you sort of flipped the location of `.fb4` and `.fb5`, so it's the rightmost purple building you are working on now. +残りのビルはあと 3 つです。 `.fb4` 要素の中に新しい `div` 要素を 2 つネストし、`fb4a` クラスと `fb4b` クラスをこの順序で設定してください。 `.fb4` と `.fb5` の位置を逆にしたことを思い出してください。つまり、現在作業しているのは右側の紫色のビルになります。 # --hints-- -You should add two `div` elements within `.fb4`. +`.fb4` 内に `div` 要素を 2 つ追加する必要があります。 ```js assert.equal(document.querySelectorAll("div.fb4 > div")?.length, 2); ``` -You should give the first new `div` a class of `fb4a`. +1 つ目の新しい `div` にクラス `fb4a` を設定する必要があります。 ```js assert.exists(document.querySelector("div.fb4a")); ``` -You should give the second new `div` a class of `fb4b`. +2 つ目の新しい `div` にクラス `fb4b` を設定する必要があります。 ```js assert.exists(document.querySelector("div.fb4b")); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992a.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992a.md index d3b19622b01..30edc13e8f8 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992a.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992a.md @@ -7,17 +7,17 @@ dashedName: step-97 # --description-- -Give `.fb4b` a `width` of `100%` and `height` of `89%`. +`.fb4b` 要素の `width` を `100%` に、`height` を `89%` に設定してください。 # --hints-- -You should give `.fb4b` a `width` of `100%`. +`.fb4b` の `width` を `100%` に設定する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getStyle(".fb4b")?.width, "100%"); ``` -You should give `.fb4b` a `height` of `89%`. +`.fb4b` の `height` を `89%` に設定する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getStyle(".fb4b")?.height, "89%"); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992b.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992b.md index 80dc81a6052..143f66f11f3 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992b.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992b.md @@ -7,17 +7,17 @@ dashedName: step-98 # --description-- -Add your `--building-color1` variable as value of the `background-color` property of `.fb4b`. Then, remove the `background-color` from `.fb4`. +`.fb4b` の `background-color` プロパティの値として、`--building-color1` 変数を追加してください。 次に、`.fb4` から `background-color` を削除してください。 # --hints-- -You should remove the `background-color` from `.fb4`. +`.fb4` から `background-color` を削除する必要があります。 ```js assert.isEmpty(new __helpers.CSSHelp(document).getStyle(".fb4")?.backgroundColor); ``` -You should give `.fb4b` a `background-color` of `--building-color1`. +`.fb4b` の `background-color` を `--building-color1` に設定する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getStyle(".fb4b")?.backgroundColor.trim(), "var(--building-color1)"); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992c.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992c.md index e60587c6590..5829eb14803 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992c.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992c.md @@ -7,17 +7,17 @@ dashedName: step-99 # --description-- -Nest six `div` elements within `.fb4b` and give them all a class of `fb4-window`. +`.fb4b` 内に 6 つの `div` 要素をネストし、それらすべてに `fb4-window` のクラスを設定してください。 # --hints-- -You should add six `div` elements within `.fb4b`. +`.fb4b` 内に `div` 要素を 6 つ追加する必要があります。 ```js assert.equal(document.querySelectorAll("div.fb4b > div")?.length, 6); ``` -You should give each new `div` a class of `fb4-window`. +それぞれの新しい `div` に `fb4-window` のクラスを設定する必要があります。 ```js assert.equal(document.querySelectorAll("div.fb4-window")?.length, 6); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992d.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992d.md index 6eebbe6fb81..583ccbd94f1 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992d.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992d.md @@ -7,23 +7,23 @@ dashedName: step-100 # --description-- -Give the `.fb4-window` elements a `width` of `30%`, `height` of `10%`, and `border-radius` of `50%`. These will make some circular windows for this building. +`.fb4-window` 要素の `width` を `30%` に、`height` を `10%` に、`border-radius` を `50%` に設定してください。 これがこのビルの円形の窓になります。 # --hints-- -You should give `.fb4-window` a `width` of `30%`. +`.fb4-window` の `width` を `30%` に設定する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getStyle(".fb4-window")?.width, "30%"); ``` -You should give `.fb4-window` a `height` of `10%`. +`.fb4-window` の `height` を `10%` に設定する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getStyle(".fb4-window")?.height, "10%"); ``` -You should give `.fb4-window` a `border-radius` of `50%`. +`.fb4-window` の`border-radius` を `50%` に設定する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getStyle(".fb4-window")?.borderRadius, "50%"); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992e.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992e.md index cb1c303cb46..783a3307617 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992e.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992e.md @@ -7,17 +7,17 @@ dashedName: step-101 # --description-- -Fill in the windows with your secondary color for this building. Also add a `margin` of `10%` to give the windows some space. +窓をこのビルのサブカラーで塗りつぶしてください。 また、`10%` の `margin` を追加して窓の間隔をあけてください。 # --hints-- -You should give `.fb4-window` a `background-color` of `--window-color1`. +`.fb4-window` の `background-color` を `--window-color1` に設定する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getStyle(".fb4-window")?.backgroundColor.trim(), "var(--window-color1)"); ``` -You should give `.fb4-window` a `margin` of `10%`. +`.fb4-window` の `margin` を `10%` に設定する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getStyle(".fb4-window")?.margin, "10%"); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992f.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992f.md index 96a0a35de1d..1683854e65b 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992f.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e992f.md @@ -7,17 +7,17 @@ dashedName: step-102 # --description-- -Add `display: flex` and `flex-wrap: wrap` to the window container. This will put your windows side by side, and then push them down to a new row when they don't fit. +窓のコンテナーに `display: flex` と `flex-wrap: wrap` を追加してください。 これで窓が横に並んで配置され、収まりきらない場合は新しい行に押し下げられます。 # --hints-- -You should give `.fb4b` a `display` of `flex`. +`.fb4b` の `display` を `flex` に設定する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getStyle(".fb4b")?.display, "flex"); ``` -You should give `.fb4b` a `flex-wrap` of `wrap`. +`.fb4b` の `flex-wrap` を `wrap` に設定する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getStyle(".fb4b")?.flexWrap, "wrap"); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9930.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9930.md index a42b43d3954..b8baa3e0dac 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9930.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9930.md @@ -7,17 +7,17 @@ dashedName: step-103 # --description-- -This building is going to have another triangle on top. Give the top section a `border-top` of `5vh solid transparent`, and a `border-left` that is `8vw`, `solid`, and uses your building color variable as the color. +このビルの上にも三角形を乗せます。 上部のセクションに対し、`border-top` は `5vh solid transparent` に設定し、`border-left` は `8vw`、`solid`、色はビルの色の変数を使用するよう設定してください。 # --hints-- -You should give `.fb4a` a `border-top` of `5vh solid transparent`. +`.fb4a` の `border-top` を `5vh solid transparent` に設定する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getStyle(".fb4a")?.borderTop.trim(), "5vh solid transparent") ``` -You should give `.fb4a` a `border-left` of `8vw solid var(--building-color1)`. +`.fb4a` の `border-left` を `8vw solid var(--building-color1)` に設定する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getStyle(".fb4a")?.borderLeft.trim(), "8vw solid var(--building-color1)") diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9931.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9931.md index 1069108a930..b214c21990a 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9931.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9931.md @@ -7,11 +7,11 @@ dashedName: step-109 # --description-- -You can remove the `background-color` for this building now, since it isn't needed. +このビルの `background-color` は不要になったので削除しましょう。 # --hints-- -You should remove the `background-color` of `.fb6`. +`.fb6` から `background-color` を削除する必要があります。 ```js assert.notMatch(code, /\.fb6\s*\{\s*[^}]*?background-color[^}]*?\}/); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9932.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9932.md index 2e11d1b021e..c0bd530d052 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9932.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9932.md @@ -7,29 +7,29 @@ dashedName: step-104 # --description-- -On to the next building! It's the green one in the foreground. Give it a `repeating-linear-gradient` with your building color from `0%` to `5%`, and `transparent` from `5%` to `10%`. +次のビルに取り掛かりましょう! 手前の緑色のビルです。 `repeating-linear-gradient` を適用して、`0%` から `5%` まではあなたの定義したビルの色、`5%` から `10%` までは `transparent` に設定してください。 # --hints-- -You should give `.fb5` a `background` property. +`.fb5` に `background` プロパティを設定する必要があります。 ```js assert.isNotEmpty(new __helpers.CSSHelp(document).getStyle(".fb5")?.background); ``` -You should give the `background` a `repeating-linear-gradient`. +`background` に `repeating-linear-gradient` を設定する必要があります。 ```js assert.include(new __helpers.CSSHelp(document).getStyle(".fb5")?.background, "repeating-linear-gradient"); ``` -You should give the `repeating-linear-gradient` a first color of `--building-color2` from `0%` to `5%`. +`repeating-linear-gradient` に、最初の色 `--building-color2` を `0%` から `5%` まで設定する必要があります。 ```js assert.match(new __helpers.CSSHelp(document).getStyle(".fb5")?.getPropVal('background', true), /repeating-linear-gradient\(var\(--building-color2\)(0%)?,var\(--building-color2\)5%/); ``` -You should give the `repeating-linear-gradient` a second color of `transparent` from `5%` to `10%`. +`repeating-linear-gradient` で 2 番目の色 `transparent` を `5%` から `10%` まで設定する必要があります。 ```js assert.match(new __helpers.CSSHelp(document).getStyle(".fb5")?.getPropVal('background', true), /repeating-linear-gradient\(var\(--building-color2\)(0%)?,var\(--building-color2\)5%,transparent5%,transparent10%\)/); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9933.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9933.md index 5e352d73b61..a5832932b0b 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9933.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9933.md @@ -7,29 +7,29 @@ dashedName: step-105 # --description-- -Add another `repeating-linear-gradient` below the one you just added. Give it a `90deg` direction, use your building color from `0%` to `12%` and window color `12%` to `44%`. This will make a bunch of rectangle windows. +先ほど追加したものの下に、もう 1 つ `repeating-linear-gradient` を追加してください。 方向を `90deg` に指定し、`0%` から `12%` までビルの色、`12%` から `44%` まで窓の色を使用してください。 これで長方形の窓がたくさんできます。 # --hints-- -You should give `.fb5` a second `repeating-linear-gradient` in the `background` property. +`.fb5` の `background` プロパティに、2 つ目の `repeating-linear-gradient` を追加する必要があります。 ```js assert.match(new __helpers.CSSHelp(document).getStyle(".fb5")?.getPropVal('background', true), /repeating-linear-gradient\(var\(--building-color2\)(0%)?,var\(--building-color2\)5%,transparent5%,transparent10%\),repeating-linear-gradient/); ``` -You should give the second `repeating-linear-gradient` a direction of `90deg`. +2 つ目の `repeating-linear-gradient` に `90deg` の方向を指定する必要があります。 ```js assert.match(new __helpers.CSSHelp(document).getStyle(".fb5")?.getPropVal('background', true), /repeating-linear-gradient\(var\(--building-color2\)(0%)?,var\(--building-color2\)5%,transparent5%,transparent10%\),repeating-linear-gradient\(90deg/); ``` -You should give the second `repeating-linear-gradient` a first color of `--building-color2` from `0%` to `12%`. +2 つ目の `repeating-linear-gradient` で最初の色 `--building-color2` を `0%` から `12%` まで設定する必要があります。 ```js assert.match(new __helpers.CSSHelp(document).getStyle(".fb5")?.getPropVal('background', true), /repeating-linear-gradient\(var\(--building-color2\)(0%)?,var\(--building-color2\)5%,transparent5%,transparent10%\),repeating-linear-gradient\(90deg,var\(--building-color2\)(0%)?,var\(--building-color2\)12%/); ``` -You should give the second `repeating-linear-gradient` a second color of `--window-color2` from `12%` to `44%`. +2 つ目の `repeating-linear-gradient` で 2 番目の色 `--window-color2` を `12%` から `44%` まで設定する必要があります。 ```js assert.match(new __helpers.CSSHelp(document).getStyle(".fb5")?.getPropVal('background', true), /repeating-linear-gradient\(var\(--building-color2\)(0%)?,var\(--building-color2\)5%,transparent5%,transparent10%\),repeating-linear-gradient\(90deg,var\(--building-color2\)(0%)?,var\(--building-color2\)12%,var\(--window-color2\)12%,var\(--window-color2\)44%\)/); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9934.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9934.md index a7ee4c3cf1e..a041dae9f11 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9934.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9934.md @@ -7,29 +7,29 @@ dashedName: step-107 # --description-- -Finally! You made it to the last building! Add a repeating gradient to it with a `90deg` direction. Use the building color from `0%` to `10%` and `transparent` from `10%` to `30%`. +ついに 最後のビルにたどり着きました! このビルに `90deg` の方向の繰り返しグラデーションを追加してください。 `0%` から `10%` までビルの色を使用し、`10%` から `30%` まで `transparent` を使用してください。 # --hints-- -You should add a `repeating-linear-gradient` to `.fb6` in the `background` property. +`.fb6` の `background` プロパティに `repeating-linear-gradient` を追加する必要があります。 ```js assert.include(new __helpers.CSSHelp(document).getStyle(".fb6")?.background, "repeating-linear-gradient"); ``` -You should give the `repeating-linear-gradient` a direction of `90deg`. +`repeating-linear-gradient` に `90deg` の方向を指定する必要があります。 ```js assert.include(new __helpers.CSSHelp(document).getStyle(".fb6")?.getPropVal('background', true), "repeating-linear-gradient(90deg"); ``` -You should give the `repeating-linear-gradient` a first color of `--building-color3` from `0%` to `10%`. +`repeating-linear-gradient` で最初の色 `--building-color3` を `0%` から `10%` まで設定する必要があります。 ```js assert.match(new __helpers.CSSHelp(document).getStyle(".fb6")?.getPropVal('background', true), /repeating-linear-gradient\(90deg,var\(--building-color3\)(0%)?,var\(--building-color3\)10%/); ``` -You should give the `repeating-linear-gradient` a second color of `transparent` from `10%` to `30%`. +`repeating-linear-gradient` で 2 番目の色 `transparent` を `10%` から `30%` まで設定する必要があります。 ```js assert.match(new __helpers.CSSHelp(document).getStyle(".fb6")?.getPropVal('background', true), /repeating-linear-gradient\(90deg,var\(--building-color3\)(0%)?,var\(--building-color3\)10%,transparent10%,transparent30%\)/); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9935.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9935.md index 3a69dde11c7..3a42971b582 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9935.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9935.md @@ -7,23 +7,23 @@ dashedName: step-108 # --description-- -Add another repeating gradient to this building; make it the same as the one you just added, except don't add the `90deg` direction and use your window color instead of the two `transparent` colors. +このビルにもう 1 つ繰り返しグラデーションを追加しましょう。先ほど追加したものと同じ設定にしますが、`90deg` の方向を追加せず、2 つの `transparent` の代わりに窓の色を使用してください。 # --hints-- -You should give `.fb6` a second `repeating-linear-gradient` in the `background` property. +`.fb6` の `background` プロパティに、2 つ目の `repeating-linear-gradient` を追加する必要があります。 ```js assert.match(new __helpers.CSSHelp(document).getStyle(".fb6")?.getPropVal('background', true), /repeating-linear-gradient\(90deg,var\(--building-color3\)(0%)?,var\(--building-color3\)10%,transparent10%,transparent30%\),repeating-linear-gradient/); ``` -You should give the second `repeating-linear-gradient` a first color of `--building-color3` from `0%` to `10%`. +2 つ目の `repeating-linear-gradient` で最初の色 `--building-color3` を `0%` から `10%` まで設定する必要があります。 ```js assert.match(new __helpers.CSSHelp(document).getStyle(".fb6")?.getPropVal('background', true), /repeating-linear-gradient\(90deg,var\(--building-color3\)(0%)?,var\(--building-color3\)10%,transparent10%,transparent30%\),repeating-linear-gradient\(var\(--building-color3\)(0%)?,var\(--building-color3\)10%/); ``` -You should give the second `repeating-linear-gradient` a second color of `--window-color3` from `10%` to `30%`. +2 つ目の `repeating-linear-gradient` で 2 番目の色 `--window-color3` を `10%` から `30%` まで設定する必要があります。 ```js assert.match(new __helpers.CSSHelp(document).getStyle(".fb6")?.getPropVal('background', true), /repeating-linear-gradient\(90deg,var\(--building-color3\)(0%)?,var\(--building-color3\)10%,transparent10%,transparent30%\),repeating-linear-gradient\(var\(--building-color3\)(0%)?,var\(--building-color3\)10%,var\(--window-color3\)10%,var\(--window-color3\)30%\)/); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9936.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9936.md index 2a27a3a0ac1..663defa5945 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9936.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9936.md @@ -7,11 +7,11 @@ dashedName: step-110 # --description-- -Okay, the buildings are done. Go back to the `*` selector and remove the `border` you applied to everything at the beginning and the buildings will come together. +以上でビルが完成しました。 `*` セレクターに戻り、はじめに全要素に適用した `border` を削除すると、ビルが組み上がります。 # --hints-- -You should remove the `border` from the `*` selector. +`*` セレクターから `border` を削除する必要があります。 ```js assert.isEmpty(new __helpers.CSSHelp(document).getStyle("*")?.border); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9937.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9937.md index debfe8d2902..ca5c29b53ba 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9937.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9937.md @@ -7,11 +7,11 @@ dashedName: step-111 # --description-- -Add `sky` as a second class to the `.background-buildings` element. You are going to make a background for the skyline. +`.background-buildings` 要素に、2 番目のクラスとして `sky` を追加してください。 スカイラインの背景を作ります。 # --hints-- -You should add a class of `sky` to `.background-buildings`. +`.background-buildings` にクラス `sky` を追加する必要があります。 ```js assert.exists(document.querySelector("div.background-buildings.sky")); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9938.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9938.md index 28c09e8267b..121ba706b50 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9938.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9938.md @@ -7,29 +7,29 @@ dashedName: step-112 # --description-- -Give the `sky` class a `radial-gradient`. Use `#ffcf33` from `0%` to `20%`, `#ffff66` at `21%`, and `#bbeeff` at `100%`. This will add circular gradient to the background that will be your sun. +`sky` クラスに `radial-gradient` を設定してください。 `0%` から `20%` までは `#ffcf33` を使用し、`21%` では `#ffff66` を使用し、`100%` では `#bbeeff` を使用します。 これで円形のグラデーションが背景に追加され、太陽になります。 # --hints-- -You should give `.sky` a `radial-gradient` in the `background` property. +`.sky` の `background` プロパティに `radial-gradient` を設定する必要があります。 ```js assert.include(new __helpers.CSSHelp(document).getStyle(".sky")?.background, "radial-gradient"); ``` -You should give the `radial-gradient` a first color of `#ffcf33`. +`radial-gradient` に最初の色 `#ffcf33` を設定する必要があります。 ```js assert.match(new __helpers.CSSHelp(document).getStyle(".sky")?.background, /radial-gradient\(rgb\(255, 207, 51\)( 0%)?, rgb\(255, 207, 51\) 20%/); ``` -You should give the `radial-gradient` a second color of `#ffff66` at `21%`. +`radial-gradient` の `21%` に 2 つ目の色 `#ffff66` を設定する必要があります。 ```js assert.match(new __helpers.CSSHelp(document).getStyle(".sky")?.background, /radial-gradient\(rgb\(255, 207, 51\)( 0%)?, rgb\(255, 207, 51\) 20%, rgb\(255, 255, 102\) 21%/); ``` -You should give the `radial-gradient` a third color of `#bbeeff` at `100%`. +`radial-gradient` の `100%` に 3 つ目の色 `#bbeeff` を設定する必要があります。 ```js assert.match(new __helpers.CSSHelp(document).getStyle(".sky")?.background, /radial-gradient\(rgb\(255, 207, 51\)( 0%)?, rgb\(255, 207, 51\) 20%, rgb\(255, 255, 102\) 21%, rgb\(187, 238, 255\) 100%\)/); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9939.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9939.md index 16e3e835858..bbcda0ff081 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9939.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e9939.md @@ -7,11 +7,11 @@ dashedName: step-113 # --description-- -At the top of the sky gradient color list, where you would put a direction for the gradient; add `circle closest-corner at 15% 15%,`. This will move the start of the gradient to `15%` from the top and left. It will make it end at the `closest-corner` and it will maintain a `circle` shape. These are some keywords built into gradients to describe how it behaves. +空のグラデーションに指定した色のリストの先頭で、グラデーションの方向を設定します。`circle closest-corner at 15% 15%,` を追加してください。 これで、グラデーションの開始位置が上端と左端から `15%` の位置に移動します。 グラデーションは `closest-corner` で終わり、`circle` の形状が保たれます。 これらはグラデーションの動作を指定するために用意されているキーワードです。 # --hints-- -You should give the `.sky` `radial-gradient` a direction of `circle closest-corner at 15% 15%`. +`.sky` の `radial-gradient` の方向として `circle closest-corner at 15% 15%` を設定する必要があります。 ```js assert.match(new __helpers.CSSHelp(document).getStyle(".sky")?.background, /radial-gradient\(circle closest-corner at 15% 15%, rgb\(255, 207, 51\)|( 0%), rgb\(255, 207, 51\) 20%, rgb\(255, 255, 102\) 21%, rgb\(187, 238, 255\) 100%\)/); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993a.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993a.md index 57054a78293..43dc4411d63 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993a.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993a.md @@ -7,7 +7,7 @@ dashedName: step-114 # --description-- -A media query can be used to change styles based on certain conditions, and they look like this: +メディアクエリを使用すると、特定の条件に基づいてスタイルを変更できます。次のように使用します: ```css @media (condition) { @@ -15,11 +15,11 @@ A media query can be used to change styles based on certain conditions, and they } ``` -Add an empty media query at the bottom of your stylesheet with a condition of `max-width: 1000px`. Styles added in here will take effect when the document size is 1000px wide or less. +スタイルシートの一番下に空のメディアクエリを追加し、`max-width: 1000px` という条件を設定してください。 ここに追加されたスタイルは、ドキュメントの幅のサイズが 1000px 以下の場合に有効になります。 # --hints-- -You should add an empty media query with `max-width: 1000px`. +`max-width: 1000px` という条件の空のメディアクエリを追加する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getCSSRules("media")?.[0]?.media?.mediaText, '(max-width: 1000px)'); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993b.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993b.md index 99410728e9e..c730d197fa7 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993b.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993b.md @@ -7,19 +7,19 @@ dashedName: step-115 # --description-- -Copy and paste your whole `sky` class along with all of its properties and values into the media query. You are going to make another color scheme for the skyline that changes it from day to night. +`sky` クラス全体を、すべてのプロパティと値を含めてコピーして、メディアクエリ内に貼り付けてください。 スカイラインを昼から夜に変えるために、もう 1 つ配色を作ります。 -Note: You are going to need to scroll past the editable region to copy the class. +注: クラスをコピーするには、スクロールして編集エリアの外 (エディタの背景がグレーの領域) を表示する必要があります。 # --hints-- -You should not delete the existing `.sky` declaration. +既存の `.sky` 宣言を削除しないでください。 ```js assert.match(new __helpers.CSSHelp(document).getStyle(".sky")?.getPropVal('background', true), /radial-gradient\(circleclosest-cornerat15%15%,rgb\(255,207,51\)(0%)?,rgb\(255,207,51\)20%,rgb\(255,255,102\)21%,rgb\(187,238,255\)100%\)/); ``` -You should copy the existing `.sky` declaration into the media query. +既存の `.sky` 宣言をメディアクエリにコピーする必要があります。 ```js assert.match(new __helpers.CSSHelp(document).getRuleListsWithinMedia("(max-width: 1000px)")?.find(x => x.selectorText===".sky")?.style?.background, /radial-gradient\(\s*circle\s+closest-corner\s+at\s+15%\s+15%\s*,\s+rgb\(\s*255\s*,\s*207\s*,\s*51\s*\)\s*(0%)?\s*,\s*rgb\(\s*255\s*,\s*207\s*,\s*51\s*\)\s+20%\s*,\s*rgb\(\s*255\s*,\s*255\s*,\s*102\s*\)\s+21%\s*,\s*rgb\(\s*187\s*,\s*238\s*,\s*255\s*\)\s+100%\s*\)/); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993c.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993c.md index 646d5e44400..84764012431 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993c.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993c.md @@ -7,23 +7,23 @@ dashedName: step-116 # --description-- -In the `sky` class of the media query, change the two `#ffcf33` color values to `#ccc`, the `#ffff66` to `#445`, and the `#bbeeff` to `#223`. Then you can resize your window to see the background change colors. +メディアクエリの `sky` クラスで、色の値の `#ffcf33` 2 つを `#ccc` に、`#ffff66` を `#445` に、`#bbeeff` を `#223` に、それぞれ変更してください。 これで、プレビューウィンドウのサイズを変更すると背景の色が変わることが確認できます。 # --hints-- -You should change the first color values from `#ffcf33` to `#ccc`. +最初の色の値を `#ffcf33` から `#ccc` に変更する必要があります。 ```js assert.match(new __helpers.CSSHelp(document).getRuleListsWithinMedia("(max-width: 1000px)")?.find(x => x.selectorText===".sky")?.style?.background, /radial-gradient\(\s*circle\s+closest-corner\s+at\s+15%\s+15%\s*,\s+rgb\(\s*204\s*,\s*204\s*,\s*204\s*\)\s*(0%)?\s*,\s*rgb\(\s*204\s*,\s*204\s*,\s*204\s*\)\s+20%/); ``` -You should change the second color value from `#ffff66` to `#445`. +2 番目の色の値を `#ffff66` から `#445` に変更する必要があります。 ```js assert.match(new __helpers.CSSHelp(document).getRuleListsWithinMedia("(max-width: 1000px)")?.find(x => x.selectorText===".sky")?.style?.background, /radial-gradient\(\s*circle\s+closest-corner\s+at\s+15%\s+15%\s*,\s+rgb\(\s*204\s*,\s*204\s*,\s*204\s*\)\s*(0%)?\s*,\s*rgb\(\s*204\s*,\s*204\s*,\s*204\s*\)\s+20%\s*,\s*rgb\(\s*68\s*,\s*68\s*,\s*85\s*\)\s+21%/); ``` -You should change the third color value from `#bbeeff` to `#223`. +3 番目の色の値を `#bbeeff` から `#223` に変更する必要があります。 ```js assert.match(new __helpers.CSSHelp(document).getRuleListsWithinMedia("(max-width: 1000px)")?.find(x => x.selectorText===".sky")?.style?.background, /radial-gradient\(\s*circle\s+closest-corner\s+at\s+15%\s+15%\s*,\s+rgb\(\s*204\s*,\s*204\s*,\s*204\s*\)\s*(0%)?\s*,\s*rgb\(\s*204\s*,\s*204\s*,\s*204\s*\)\s+20%\s*,\s*rgb\(\s*68\s*,\s*68\s*,\s*85\s*\)\s+21%\s*,\s*rgb\(\s*34\s*,\s*34\s*,\s*51\s*\)\s+100%\s*\)/); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993d.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993d.md index 44359cef868..ccffeeb85fa 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993d.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993d.md @@ -7,35 +7,35 @@ dashedName: step-117 # --description-- -Add a `:root` selector to the top of your media query. Then redefine all four of the `--building-color` variables to use the value `#000` there. +メディアクエリの一番上に `:root` セレクターを追加してください。 次に、4 つすべての `--building-color` 変数について、値 `#000` を使用するように再定義してください。 # --hints-- -You should add a `:root` selector to the media query. +メディアクエリに `:root` セレクターを追加する必要があります。 ```js assert.notDeepEqual(new __helpers.CSSHelp(document).getRuleListsWithinMedia("(max-width: 1000px)")?.find(x=>x.selectorText === ":root"), undefined); ``` -You should add `--building-color1` with a value of `#000`. +値が `#000` の `--building-color1` を追加する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getRuleListsWithinMedia("(max-width: 1000px)")?.find(x=>x.selectorText === ":root")?.style?.getPropertyValue("--building-color1")?.trim(), "#000"); ``` -You should add `--building-color2` with a value of `#000`. +値が `#000` の `--building-color2` を追加する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getRuleListsWithinMedia("(max-width: 1000px)")?.find(x=>x.selectorText === ":root")?.style?.getPropertyValue("--building-color2")?.trim(), "#000"); ``` -You should add `--building-color3` with a value of `#000`. +値が `#000` の `--building-color3` を追加する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getRuleListsWithinMedia("(max-width: 1000px)")?.find(x=>x.selectorText === ":root")?.style?.getPropertyValue("--building-color3")?.trim(), "#000"); ``` -You should add `--building-color4` with a value of `#000`. +値が `#000` の `--building-color4` を追加する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getRuleListsWithinMedia("(max-width: 1000px)")?.find(x=>x.selectorText === ":root")?.style?.getPropertyValue("--building-color4")?.trim(), "#000"); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993e.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993e.md index d1ad5c5856f..d131bcbb555 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993e.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e993e.md @@ -7,31 +7,31 @@ dashedName: step-118 # --description-- -Lastly, in the `:root` selector of the media query, redefine all four of the `--window-color` variables to use `#777`. When you're done, resize the window and watch it go from day to night. +最後に、メディアクエリの `:root` セレクターで、4 つすべての `--window-color` 変数について `#777` を使用するように再定義してください。 設定を終えたら、ウィンドウのサイズを変更して、昼から夜への変化を確認してください。 -Variables are primarily used with colors, and that's how you used them here. But they can be given any value and used on any property. Your project looks great! +変数は色と一緒に使われることが多く、この例でもそのような使い方をしました。 しかし、変数には任意の値を設定でき、任意のプロパティで使用できます。 素晴らしいプロジェクトが出来上がりました! # --hints-- -You should add `--window-color1` with a value of `#777`. +値が `#777` の `--window-color1` を追加する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getRuleListsWithinMedia("(max-width: 1000px)")?.find(x=>x.selectorText === ":root")?.style?.getPropertyValue("--window-color1")?.trim(), "#777"); ``` -You should add `--window-color2` with a value of `#777`. +値が `#777` の `--window-color2` を追加する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getRuleListsWithinMedia("(max-width: 1000px)")?.find(x=>x.selectorText === ":root")?.style?.getPropertyValue("--window-color2")?.trim(), "#777"); ``` -You should add `--window-color3` with a value of `#777`. +値が `#777` の `--window-color3` を追加する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getRuleListsWithinMedia("(max-width: 1000px)")?.find(x=>x.selectorText === ":root")?.style?.getPropertyValue("--window-color3")?.trim(), "#777"); ``` -You should add `--window-color4` with a value of `#777`. +値が `#777` の `--window-color4` を追加する必要があります。 ```js assert.equal(new __helpers.CSSHelp(document).getRuleListsWithinMedia("(max-width: 1000px)")?.find(x=>x.selectorText === ":root")?.style?.getPropertyValue("--window-color4")?.trim(), "#777"); diff --git a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md index aacad94041d..f9bc1db22e3 100644 --- a/curriculum/challenges/japanese/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md +++ b/curriculum/challenges/japanese/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md @@ -51,7 +51,17 @@ assert( assert($('input')[0].hasAttribute('type')); ``` -新しい `input` 要素には `type` 属性があり、値が `radio` に設定されている必要があります。 値が設定されていないか、誤字脱字があります。 属性値は引用符で囲むことを忘れないでください。 +Your new `input` element should have only one `type` attribute. Remove any extras. + +```js +assert($('input')[0] + .getAttributeNames() + .filter(attr => attr === 'type') + .length === 1 +); +``` + +Your new `input` element should have a `type` attribute with the value `radio`. You have either omitted the value or have a typo. Remember that attribute values should be surrounded with quotation marks. ```js assert( @@ -61,20 +71,20 @@ assert( ); ``` -新しい `input` 要素の `type` 属性は `radio` に設定されていますが、属性の値は常に引用符で囲むことが推奨されています。 +Although you have set the new `input` element's `type` attribute to `radio`, it is recommended to always surround the value of an attribute with quotation marks. ```js assert(!/\<\s*input\s+type\s*=\s*radio/i.test(code)); ``` -`radio` ボタンのテキスト `Indoor` は、ラジオボタンの前ではなく後に配置してください。 +The `radio` button's `Indoor` text should be located after it instead of before it. ```js const radioInputElem = $('input')[0]; assert(!radioInputElem.previousSibling.nodeValue.match(/Indoor/i)); ``` -`Indoor` というテキストは `radio` ボタンの右側に配置してください。 テキストが設定されていないか、誤字脱字があります。 +The text `Indoor` should be located directly to the right of your `radio` button. You have either omitted the text or have a typo. ```js const radioInputElem = $('input')[0]; @@ -125,6 +135,7 @@ assert(

Cat Form

--fcc-editable-region-- + --fcc-editable-region-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md index 02ffeb838f6..bb4bb752806 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa226207f33d3ad4c6f546.md @@ -7,7 +7,7 @@ dashedName: step-154 # --description-- -Use the `+=` operator to add `Your [weapon] breaks.` to the end of `text.innerText`, replacing `weapon` with the last item in the `inventory` array. You can get this last item by using `inventory.pop()`, which will remove the last item in the array AND return it so it appears in your string. +Use the `+=` operator to add `Your [weapon] breaks.`, with a space in front of `Your`, to the end of `text.innerText`. Replace `[weapon]` with the last item in the `inventory` array using `inventory.pop()`, which will remove the last item in the array AND return it so it appears in your string. # --hints-- @@ -24,7 +24,7 @@ You should use the `pop` method on the `inventory` array. assert.match(attack.toString(), /inventory\.pop\(\)/); ``` -You should add the string " Your " to `text.innerText`. Remember that spacing matters. +You should add `Your`, with a space before and after it, to `text.innerText`. ```js assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1/); @@ -37,7 +37,7 @@ console.log(attack.toString()); assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1\s*\+\s*inventory\.pop\(\)/); ``` -You should add `breaks.` to the `"Your " + inventory.pop()` string. +You should add `breaks.`, with a space in front of it, to the end of your string. ```js assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1\s*\+\s*inventory\.pop\(\)\s*\+\s*('|")\sbreaks\.\2/); diff --git a/curriculum/challenges/portuguese/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md b/curriculum/challenges/portuguese/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md index 4d6cd4ab4f6..d675d137d66 100644 --- a/curriculum/challenges/portuguese/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md +++ b/curriculum/challenges/portuguese/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md @@ -119,7 +119,7 @@ const el = document.getElementById('email') assert(!!el && el.required) ``` -O elemento `#email` deve ser um descendente de `#survey-form` +Your `#email` should be a descendant of `#survey-form`. ```js const el = document.querySelector('#survey-form #email') diff --git a/curriculum/challenges/portuguese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md b/curriculum/challenges/portuguese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md index d8ea440526b..37cb8ffc5a5 100644 --- a/curriculum/challenges/portuguese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md +++ b/curriculum/challenges/portuguese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md @@ -53,7 +53,7 @@ Você deve usar desestruturação para criar a variável `lowToday`. ```js assert( code.match( - /(var|const|let)\s*{\s*today\s*:\s*{\s*(low\s*:\s*lowToday[^}]*|[^,]*,\s*low\s*:\s*lowToday\s*)}\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g + /(var|const|let)\s*{\s*today\s*:\s*{\s*(low\s*:\s*lowToday[^}]*|[^,]*,\s*low\s*:\s*lowToday\s*)},?\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g ) ); ``` @@ -63,7 +63,7 @@ Você deve usar desestruturação para criar a variável `highToday`. ```js assert( code.match( - /(var|const|let)\s*{\s*today\s*:\s*{\s*(high\s*:\s*highToday[^}]*|[^,]*,\s*high\s*:\s*highToday\s*)}\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g + /(var|const|let)\s*{\s*today\s*:\s*{\s*(high\s*:\s*highToday[^}]*|[^,]*,\s*high\s*:\s*highToday,?\s*)},?\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g ) ); ``` diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md index 278bb774e38..e3f062a4476 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-128-hexagonal-tile-differences.md @@ -56,46 +56,57 @@ hexagonalTile(10); # --solutions-- ```js -const NUM_PRIMES = 840000; -const PRIME_SEIVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SEIVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) { - PRIME_SEIVE[j] = false; +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); + + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } } } - } -})(NUM_PRIMES); -function isPrime(num) { - if (num === 2) return true; - else if (num % 2 === 0) return false - else return PRIME_SEIVE[(num - 3) / 2]; -} + this._seive = seive; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } +}; function hexagonalTile(tileIndex) { + const primeSeive = new PrimeSeive(tileIndex * 420); let count = 1; let n = 1; let number = 0; while (count < tileIndex) { - if (isPrime(6*n - 1) && - isPrime(6*n + 1) && - isPrime(12*n + 5)) { + if (primeSeive.isPrime(6*n - 1) && + primeSeive.isPrime(6*n + 1) && + primeSeive.isPrime(12*n + 5)) { number = 3*n*n - 3*n + 2; count++; if (count >= tileIndex) break; } - if (isPrime(6*n + 5) && - isPrime(6*n - 1) && - isPrime(12*n - 7) && n != 1) { + if (primeSeive.isPrime(6*n + 5) && + primeSeive.isPrime(6*n - 1) && + primeSeive.isPrime(12*n - 7) && n != 1) { number = 3*n*n + 3*n + 1; count++; } diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md index a3e5fb340ea..f90162739b4 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-47-distinct-primes-factors.md @@ -67,25 +67,28 @@ distinctPrimeFactors(4, 4); # --solutions-- ```js -// Initalize factor count with seive -const NUMFACTORS = Array(135000).fill(0); -(function initFactors(num) { - for (let i = 2; i < num; i++) - if (NUMFACTORS[i] === 0) - for (let j = i; j < num; j += i) - NUMFACTORS[j]++; -})(135000); - function distinctPrimeFactors(targetNumPrimes, targetConsecutive) { + const primeLimit = targetNumPrimes * targetConsecutive * 10000; + const numFactors = Array(primeLimit).fill(0); + let numConsecutive = 0; - let currNumber = 10; - while (numConsecutive < targetConsecutive) { - if (NUMFACTORS[currNumber] === targetNumPrimes) + for (let i = 2; i < primeLimit; i++) { + if (numFactors[i] === targetNumPrimes) { + // Current number is composite with target num factors numConsecutive++; - else + if (numConsecutive === targetConsecutive) { + return i - numConsecutive + 1; + } + } else { + // Current number is not matching composite numConsecutive = 0; - currNumber++; + if (numFactors[i] === 0) { + // Current number is prime + for (let j = i; j < primeLimit; j += i) { + numFactors[j]++; + } + } + } } - return currNumber - targetConsecutive; } ``` diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md index befb04b13c6..804942e0ca8 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-50-consecutive-prime-sum.md @@ -54,40 +54,56 @@ consecutivePrimeSum(1000000); # --solutions-- ```js -// Initalize prime number list with sieve -const NUM_PRIMES = 1000000; -const PRIMES = [2]; -const PRIME_SIEVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SIEVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - PRIMES.push(prime); - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) - PRIME_SIEVE[j] = false; - } - } - for (let i = sqrtUpper + 1; i < upper; i++) { - if (PRIME_SIEVE[i]) - PRIMES.push(2 * i + 3); - } -})(NUM_PRIMES); +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const primes = [2]; + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); -function isPrime(num) { - if (num === 2) - return true; - else if (num % 2 === 0) - return false - else - return PRIME_SIEVE[(num - 3) / 2]; -} + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + primes.push(prime); + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } + } + } + for (let i = sqrtUpper + 1; i < upper; i++) { + if (seive[i]) { + primes.push(2 * i + 3); + } + } + + this._seive = seive; + this._primes = primes; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } + + get primes() { + return this._primes; + } +}; function consecutivePrimeSum(limit) { + // Initalize seive + const primeSeive = new PrimeSeive(limit); + // Initalize for longest sum < 100 let bestPrime = 41; let bestI = 0; @@ -102,20 +118,20 @@ function consecutivePrimeSum(limit) { // -- Loop while pushing j towards end of PRIMES list // keeping sum under limit while (currSum < limit) { - if (isPrime(currSum)) { + if (primeSeive.isPrime(currSum)) { bestPrime = sumOfCurrRange = currSum; bestI = i; bestJ = j; } // -- Increment inner loop j++; - currSum += PRIMES[j]; + currSum += primeSeive.primes[j]; } // -- Increment outer loop i++; j = i + (bestJ - bestI); - sumOfCurrRange -= PRIMES[i - 1]; - sumOfCurrRange += PRIMES[j]; + sumOfCurrRange -= primeSeive.primes[i - 1]; + sumOfCurrRange += primeSeive.primes[j]; } // Return return bestPrime; diff --git a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md index 27d0530f1f5..67902e726f7 100644 --- a/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md +++ b/curriculum/challenges/portuguese/10-coding-interview-prep/project-euler/problem-51-prime-digit-replacements.md @@ -56,31 +56,43 @@ primeDigitReplacements(6); # --solutions-- ```js -const NUM_PRIMES = 1000000; -const PRIME_SEIVE = Array(Math.floor((NUM_PRIMES-1)/2)).fill(true); -(function initPrimes(num) { - const upper = Math.floor((num - 1) / 2); - const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); - for (let i = 0; i <= sqrtUpper; i++) { - if (PRIME_SEIVE[i]) { - // Mark value in PRIMES array - const prime = 2 * i + 3; - // Mark all multiples of this number as false (not prime) - const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; - for (let j = primeSqaredIndex; j < upper; j += prime) { - PRIME_SEIVE[j] = false; +class PrimeSeive { + constructor(num) { + const seive = Array(Math.floor((num - 1) / 2)).fill(true); + const upper = Math.floor((num - 1) / 2); + const sqrtUpper = Math.floor((Math.sqrt(num) - 1) / 2); + + for (let i = 0; i <= sqrtUpper; i++) { + if (seive[i]) { + // Mark value in seive array + const prime = 2 * i + 3; + // Mark all multiples of this number as false (not prime) + const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3; + for (let j = primeSqaredIndex; j < upper; j += prime) { + seive[j] = false; + } } } - } -})(NUM_PRIMES); -function isPrime(num) { - if (num === 2) return true; - else if (num % 2 === 0) return false - else return PRIME_SEIVE[(num - 3) / 2]; -} + this._seive = seive; + } + + isPrime(num) { + return num === 2 + ? true + : num % 2 === 0 + ? false + : this.isOddPrime(num); + } + + isOddPrime(num) { + return this._seive[(num - 3) / 2]; + } +}; function primeDigitReplacements(n) { + const primeSeive = new PrimeSeive(n * n * n * 2000); + function isNFamily(number, n) { const prime = number.toString(); const lastDigit = prime[prime.length - 1]; @@ -114,12 +126,12 @@ function primeDigitReplacements(n) { function isPartOfFamily(number, prime) { return ( - isPrime(number) && number.toString().length === prime.length + primeSeive.isPrime(number) && number.toString().length === prime.length ); } for (let number = 1; number < 125000; number++) { - if (isPrime(number) && isNFamily(number, n)) { + if (primeSeive.isPrime(number) && isNFamily(number, n)) { return number; } } diff --git a/curriculum/challenges/portuguese/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md b/curriculum/challenges/portuguese/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md index 4d6cd4ab4f6..d675d137d66 100644 --- a/curriculum/challenges/portuguese/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md +++ b/curriculum/challenges/portuguese/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md @@ -119,7 +119,7 @@ const el = document.getElementById('email') assert(!!el && el.required) ``` -O elemento `#email` deve ser um descendente de `#survey-form` +Your `#email` should be a descendant of `#survey-form`. ```js const el = document.querySelector('#survey-form #email') diff --git a/curriculum/challenges/portuguese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md b/curriculum/challenges/portuguese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md index e125b5f75a7..36da2d24380 100644 --- a/curriculum/challenges/portuguese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md +++ b/curriculum/challenges/portuguese/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98de.md @@ -7,7 +7,7 @@ dashedName: step-22 # --description-- -Crie uma variável abaixo da outra chamada `--building-color2` e dê a ela um valor de `#66cc99`. Em seguida, defina-a como a `background-color` de `.bb2`. +Create a new variable below your `--building-color1` variable. Name your new variable `--building-color2` and give it a value of `#66cc99`. Then set it as the `background-color` of `.bb2`. # --hints-- @@ -17,7 +17,7 @@ Você deve definir uma nova propriedade variável chamada `--building-color2`. assert.exists(new __helpers.CSSHelp(document).isPropertyUsed('--building-color2')); ``` -Você deve dar a `--building-color2` um valor de `#66cc99`. +You should give `--building-color2` a value of `#66cc99` within the `.bb1` class. ```js assert.equal(new __helpers.CSSHelp(document).getStyle('.bb1')?.getPropertyValue('--building-color2').trim(), '#66cc99'); diff --git a/curriculum/challenges/portuguese/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md b/curriculum/challenges/portuguese/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md index e490d4365e6..dab6ad621c4 100644 --- a/curriculum/challenges/portuguese/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md +++ b/curriculum/challenges/portuguese/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804dc.md @@ -51,7 +51,17 @@ O novo elemento `input` não tem um atributo `type`. Verifique se há um espaço assert($('input')[0].hasAttribute('type')); ``` -O novo elemento `input` deve ter o atributo `type` com o valor `radio`. Você omitiu o valor ou tem um erro de digitação. Lembre-se de que os valores dos atributos devem estar cercados com aspas. +Your new `input` element should have only one `type` attribute. Remove any extras. + +```js +assert($('input')[0] + .getAttributeNames() + .filter(attr => attr === 'type') + .length === 1 +); +``` + +Your new `input` element should have a `type` attribute with the value `radio`. You have either omitted the value or have a typo. Remember that attribute values should be surrounded with quotation marks. ```js assert( @@ -61,20 +71,20 @@ assert( ); ``` -Embora você tenha definido o atributo `type` do elemento `input` com o valor `radio`, é recomendável sempre cercar o valor de um atributo com aspas. +Although you have set the new `input` element's `type` attribute to `radio`, it is recommended to always surround the value of an attribute with quotation marks. ```js assert(!/\<\s*input\s+type\s*=\s*radio/i.test(code)); ``` -O texto do botão `radio` deve ser `Indoor` e estar localizado depois do botão em vez de antes dele. +The `radio` button's `Indoor` text should be located after it instead of before it. ```js const radioInputElem = $('input')[0]; assert(!radioInputElem.previousSibling.nodeValue.match(/Indoor/i)); ``` -O texto `Indoor` deve estar localizado diretamente à direita do seu botão `radio`. Você omitiu o texto ou tem um erro de digitação. +The text `Indoor` should be located directly to the right of your `radio` button. You have either omitted the text or have a typo. ```js const radioInputElem = $('input')[0]; @@ -125,6 +135,7 @@ assert(

Cat Form

--fcc-editable-region-- + --fcc-editable-region-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a115879a6d51422652cbfc.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a115879a6d51422652cbfc.md index 02a51b6a178..c00700aa47f 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a115879a6d51422652cbfc.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a115879a6d51422652cbfc.md @@ -1,47 +1,47 @@ --- id: 62a115879a6d51422652cbfc -title: Step 2 +title: Passo 2 challengeType: 0 dashedName: step-2 --- # --description-- -Create four `div` elements within your `#game` element. Give them the following respective `id` values, in order: `stats`, `controls`, `monsterStats`, and `text`. +Crie quatro elementos `div` dentro do elemento `#game`. Dê a eles os seguintes valores de `id`, na ordem: `stats`, `controls`, `monsterStats` e `text`. # --hints-- -You should create four new `div` elements. +Você deve criar quatro elementos `div`. ```js assert.equal(document.querySelectorAll('div')?.length, 5); ``` -You should give one of the new `div` elements an `id` of `stats`. +Você deve dar a um dos novos elementos `div` um `id` de `stats`. ```js assert.exists(document.querySelector('div#stats')); ``` -You should give one of the new `div` elements an `id` of `controls`. +Você deve dar a um dos novos elementos `div` um `id` de `controls`. ```js assert.exists(document.querySelector('div#controls')); ``` -You should give one of the new `div` elements an `id` of `monsterStats`. +Você deve dar a um dos novos elementos `div` um `id` de `monsterStats`. ```js assert.exists(document.querySelector('div#monsterStats')); ``` -You should give one of the new `div` elements an `id` of `text`. +Você deve dar a um dos novos elementos `div` um `id` de `text`. ```js assert.exists(document.querySelector('div#text')); ``` -You should place the new `div` elements in the correct order. +Você deve colocar os novos elementos `div` na ordem correta. ```js function __t(a, b) { @@ -50,7 +50,7 @@ function __t(a, b) { assert(__t('div#stats','controls') && __t('div#controls','monsterStats') && __t('div#monsterStats','text')); ``` -You should place the new `div` elements within the `#game` element. +Você deve colocar os novos elementos `div` dentro do elemento `#game`. ```js assert.equal(document.querySelector('#game')?.children?.length, 4); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a1166ed9a56d439c0770e7.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a1166ed9a56d439c0770e7.md index 32588eccbae..f21e7d5efbc 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a1166ed9a56d439c0770e7.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a1166ed9a56d439c0770e7.md @@ -1,42 +1,42 @@ --- id: 62a1166ed9a56d439c0770e7 -title: Step 3 +title: Passo 3 challengeType: 0 dashedName: step-3 --- # --description-- -Create three `span` elements within your `#stats` element. Give each of them the class `stat`. Then give the first one the text `XP: 0`, the second one the text `Health: 100`, and the third one the text `Gold: 50`. +Crie três elementos `span` dentro do elemento `#stats`. Dê a cada uma deles a classe `stat`. Em seguida, dê ao primeiro o texto `XP: 0`, ao segundo o texto `Health: 100` e ao terceiro o texto `Gold: 50`. # --hints-- -You should have three `span` elements within the `#stats` element. +Você precisa de três elementos `span` dentro do elemento `#stats`. ```js const spans = document.querySelectorAll('#stats > span'); assert.equal(spans?.length, 3); ``` -You should give the new three `span` elements a class of `stat`. +Você deve dar aos três novos elementos `span` uma classe chamada `stat`. ```js assert.exists(document.querySelectorAll('#stats > .stat')?.length, 3); ``` -Your first `.stat` element should have the provided text `XP: 0`. +O primeiro elemento `.stat` deve ter o texto `XP: 0` fornecido. ```js assert(document.querySelectorAll('#stats > .stat')?.[0]?.innerText === 'XP: 0'); ``` -Your second `.stat` element should have the provided text `Health: 100`. +O segundo elemento `.stat` deve ter o texto `Health: 100` fornecido. ```js assert(document.querySelectorAll('#stats > .stat')?.[1]?.innerText === 'Health: 100'); ``` -Your third `.stat` element should have the provided text `Gold: 50`. +O terceiro elemento `.stat` deve ter o texto `Gold: 50` fornecido. ```js assert(document.querySelectorAll('#stats > .stat')?.[2]?.innerText === 'Gold: 50'); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a23c1d505bfa13747c8a9b.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a23c1d505bfa13747c8a9b.md index 5c62cdc804a..8d766cf14c5 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a23c1d505bfa13747c8a9b.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a23c1d505bfa13747c8a9b.md @@ -1,17 +1,17 @@ --- id: 62a23c1d505bfa13747c8a9b -title: Step 4 +title: Passo 4 challengeType: 0 dashedName: step-4 --- # --description-- -Wrap the numbers `0`, `100`, and `50` in `span` elements, and wrap those new `span` elements in `strong` elements. Then give your new `span` elements `id` values of `xpText`, `healthText`, and `goldText`, respectively. +Envolva os números `0`, `100` e `50` em elementos `span`, e envolva os novos elementos `span` em elementos `strong`. Em seguida, dê aos novos elementos `span` valores de `id` de `xpText`, `healthText` e `goldText`, respectivamente. # --hints-- -You should add a `strong` element in your first `.stat` element. +Você deve adicionar um elemento `strong` dentro do primeiro elemento `.stat`. ```js const stat = document.querySelectorAll('.stat')[0]; @@ -19,7 +19,7 @@ const strong = stat?.querySelector('strong'); assert.exists(strong); ``` -Your first new `strong` element should have a `span` element. +O primeiro novo elemento `strong` deve ter um elemento `span`. ```js const stat = document.querySelectorAll('.stat')[0]; @@ -28,7 +28,7 @@ const span = strong?.querySelector('span'); assert.exists(span); ``` -Your first nested `span` element should have the `id` of `xpText`. +O primeiro elemento `span` aninhado deve ter o `id` of `xpText`. ```js const stat = document.querySelectorAll('.stat')[0]; @@ -37,7 +37,7 @@ const span = strong?.querySelector('span'); assert.equal(span?.id, 'xpText'); ``` -Your first `span` element should be wrapped around the text `0`. +O primeiro elemento `span` deve encapsular o texto `0`. ```js const stat = document.querySelectorAll('.stat')[0]; @@ -46,14 +46,14 @@ const span = strong?.querySelector('span'); assert.equal(span.innerText, '0'); ``` -The text of your first `.stat` element should still be `XP: 0`. +O texto do primeiro elemento `.stat` ainda deve ser `XP: 0`. ```js const stat = document.querySelectorAll('.stat')[0]; assert.equal(stat.innerText, 'XP: 0'); ``` -You should add a `strong` element in your second `.stat` element. +Você deve adicionar um elemento `strong` dentro do segundo elemento `.stat`. ```js const stat = document.querySelectorAll('.stat')[1]; @@ -61,7 +61,7 @@ const strong = stat?.querySelector('strong'); assert.exists(strong); ``` -Your second new `strong` element should have a `span` element. +O segundo novo elemento `strong` deve ter um elemento `span`. ```js const stat = document.querySelectorAll('.stat')[1]; @@ -70,7 +70,7 @@ const span = strong?.querySelector('span'); assert.exists(span); ``` -Your second nested `span` element should have the `id` of `healthText`. +O segundo elemento `span` aninhado deve ter o `id` de `healthText`. ```js const stat = document.querySelectorAll('.stat')[1]; @@ -79,7 +79,7 @@ const span = strong?.querySelector('span'); assert.equal(span?.id, 'healthText'); ``` -Your second `span` element should be wrapped around the text `100`. +O segundo elemento `span` deve encapsular o texto `100`. ```js const stat = document.querySelectorAll('.stat')[1]; @@ -88,14 +88,14 @@ const span = strong?.querySelector('span'); assert.equal(span.innerText, '100'); ``` -The text of your second `.stat` element should still be `Health: 100`. +O texto do segundo elemento `.stat` ainda deve ser `Health: 100`. ```js const stat = document.querySelectorAll('.stat')[1]; assert.equal(stat.innerText, 'Health: 100'); ``` -You should add a `strong` element in your third `.stat` element. +Você deve adicionar um elemento `strong` dentro do terceiro elemento `.stat`. ```js const stat = document.querySelectorAll('.stat')[2]; @@ -103,7 +103,7 @@ const strong = stat?.querySelector('strong'); assert.exists(strong); ``` -Your third new `strong` element should have a `span` element. +O terceiro novo elemento `strong` deve ter um elemento `span`. ```js const stat = document.querySelectorAll('.stat')[2]; @@ -112,7 +112,7 @@ const span = strong?.querySelector('span'); assert.exists(span); ``` -Your third nested `span` element should have the `id` of `goldText`. +O terceiro elemento `span` aninhado deve ter o `id` de `goldText`. ```js const stat = document.querySelectorAll('.stat')[2]; @@ -121,7 +121,7 @@ const span = strong?.querySelector('span'); assert.equal(span?.id, 'goldText'); ``` -Your third `span` element should be wrapped around the text `50`. +O terceiro elemento `span` deve encapsular o texto `50`. ```js const stat = document.querySelectorAll('.stat')[2]; @@ -130,7 +130,7 @@ const span = strong?.querySelector('span'); assert.equal(span.innerText, '50'); ``` -The text of your third `.stat` element should still be `Gold: 50`. +O texto do terceiro elemento `.stat` ainda deve ser `Gold: 50`. ```js const stat = document.querySelectorAll('.stat')[2]; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a23cb9bc467a147516b500.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a23cb9bc467a147516b500.md index 5a36b14c83c..4141ecb1a2c 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a23cb9bc467a147516b500.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a23cb9bc467a147516b500.md @@ -1,17 +1,17 @@ --- id: 62a23cb9bc467a147516b500 -title: Step 5 +title: Passo 5 challengeType: 0 dashedName: step-5 --- # --description-- -For your `#controls` element, create three `button` elements. The first should have the `id` set to `button1`, and the text `Go to store`. The second should have the `id` set to `button2`, and the text `Go to cave`. The third should have the `id` set to `button3`, and the text `Fight dragon`. +Para o elemento `#controls`, crie três elementos `button`. O primeiro deve ter o `id` definido como `button1` e o texto `Go to store`. O segundo deve ter o `id` definido como `button2` e o texto `Go to cave`. O terceiro deve ter o `id` definido como `button3` e o texto `Fight dragon`. # --hints-- -You should add three `button` elements to your `#controls` element. +Você precisa adicionar três elementos `button` ao elemento `#controls`. ```js const buttons = document.querySelectorAll('#controls > button'); @@ -19,7 +19,7 @@ assert.exists(buttons); assert.equal(buttons.length, 3); ``` -Your first button should have the `id` set to `button1`. +O primeiro botão deve ter o atributo `id` definido como `button1`. ```js const buttons = document.querySelectorAll('#controls > button'); @@ -27,7 +27,7 @@ const button1 = buttons[0]; assert.equal(button1.id, 'button1'); ``` -Your first button should have the text `Go to store`. +O primeiro botão deve ter o texto `Go to store`. ```js const buttons = document.querySelectorAll('#controls > button'); @@ -35,7 +35,7 @@ const button1 = buttons[0]; assert.equal(button1.innerText, 'Go to store'); ``` -Your second button should have the `id` set to `button2`. +O segundo botão deve ter o atributo `id` definido como `button2`. ```js const buttons = document.querySelectorAll('#controls > button'); @@ -43,7 +43,7 @@ const button2 = buttons[1]; assert.equal(button2.id, 'button2'); ``` -Your second button should have the text `Go to cave`. +O segundo botão deve ter o texto `Go to cave`. ```js const buttons = document.querySelectorAll('#controls > button'); @@ -51,7 +51,7 @@ const button2 = buttons[1]; assert.equal(button2.innerText, 'Go to cave'); ``` -Your third button should have the `id` set to `button3`. +O terceiro botão deve ter o atributo `id` definido como `button3`. ```js const buttons = document.querySelectorAll('#controls > button'); @@ -59,7 +59,7 @@ const button3 = buttons[2]; assert.equal(button3.id, 'button3'); ``` -Your third button should have the text `Fight dragon`. +O terceiro botão deve ter o texto `Fight dragon`. ```js const buttons = document.querySelectorAll('#controls > button'); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a2401b9842721796b72850.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a2401b9842721796b72850.md index 2ffdc00b64b..dafa2b673e8 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a2401b9842721796b72850.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a2401b9842721796b72850.md @@ -1,13 +1,13 @@ --- id: 62a2401b9842721796b72850 -title: Step 7 +title: Passo 7 challengeType: 0 dashedName: step-7 --- # --description-- -Give your `#text` element the following text: +Dê ao elemento `#text` o seguinte texto: ```markup Welcome to Dragon Repeller. You must defeat the dragon that is preventing people from leaving the town. @@ -16,7 +16,7 @@ You are in the town square. Where do you want to go? Use the buttons above. # --hints-- -Your `#text` element should have the above quoted text. +O novo elemento `#text` deve ter o texto citado acima. ```js const text = document.querySelector('#text'); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a24068d60b671847d1d4e2.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a24068d60b671847d1d4e2.md index 4a5a57ad8cf..dfc6c9b49b8 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a24068d60b671847d1d4e2.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a24068d60b671847d1d4e2.md @@ -1,24 +1,24 @@ --- id: 62a24068d60b671847d1d4e2 -title: Step 8 +title: Passo 8 challengeType: 0 dashedName: step-8 --- # --description-- -Now we need some quick styling. Start by giving the `body` a `background-color` set to `darkblue`. +Agora, precisamos de um estilo rápido. Comece dando ao `body` um `background-color` definido como `darkblue`. # --hints-- -You should have a `body` selector. +Você deve ter um seletor `body`. ```js const body = new __helpers.CSSHelp(document).getStyle('body'); assert.exists(body); ``` -Your `body` selector should have a `background-color` property set to `darkblue`. +O seletor `body` deve ter a propriedade `background-color` definida como `darkblue`. ```js const background = new __helpers.CSSHelp(document).getStyle('body')?.getPropertyValue('background-color'); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a2409897ec621942234cf6.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a2409897ec621942234cf6.md index d59d46387be..da5ea121b64 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a2409897ec621942234cf6.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a2409897ec621942234cf6.md @@ -1,38 +1,38 @@ --- id: 62a2409897ec621942234cf6 -title: Step 9 +title: Passo 9 challengeType: 0 dashedName: step-9 --- # --description-- -Give the `#text` element a `background-color` of `black`, a `color` of `white`, and `10px` of padding on all sides. +Dê ao elemento `#text` uma `background-color` de `black`, uma `color` de `white` e `10px` de espaçamento em todos os lados. # --hints-- -You should have a `#text` selector. +Você deve ter um seletor `#text`. ```js const text = new __helpers.CSSHelp(document).getStyle('#text'); assert.exists(text); ``` -Your `#text` element should have a `background-color` of `black`. +O elemento `#text` deve ter uma `background-color` com o valor de `black`. ```js const background = new __helpers.CSSHelp(document).getStyle('#text')?.getPropertyValue('background-color'); assert.equal(background, 'black'); ``` -Your `#text` element should have a `color` of `white`. +O elemento `#text` deve ter o atributo `color` com o valor `white`. ```js const color = new __helpers.CSSHelp(document).getStyle('#text')?.getPropertyValue('color'); assert.equal(color, 'white'); ``` -Your `#text` element should have `10px` of padding on all sides. +O elemento `#text` deve ter `10px` de espaçamento em todos os lados. ```js const padding = new __helpers.CSSHelp(document).getStyle('#text')?.getPropertyValue('padding'); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a240c67f3dbb1a1e6d95ee.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a240c67f3dbb1a1e6d95ee.md index 2a21ac2c341..bcafbbea938 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a240c67f3dbb1a1e6d95ee.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a240c67f3dbb1a1e6d95ee.md @@ -1,59 +1,59 @@ --- id: 62a240c67f3dbb1a1e6d95ee -title: Step 10 +title: Passo 10 challengeType: 0 dashedName: step-10 --- # --description-- -Give your `#game` a maximum width of `500px` and a maximum height of `400px`. Set the `background-color` to `lightgray` and the `color` to `white`. Finally, use margins to center it and give it `10px` of padding on all four sides. +Dê ao `#game` uma largura máxima de `500px` e uma altura máxima de `400px`. Defina a `background-color` como `lightgray` e a `color` como `white`. Finalmente, use margens para centralizá-lo e dar-lhe `10px` de preenchimento em todos os quatro lados. # --hints-- -You should have a `#game` selector. +Você deve ter um seletor `#game`. ```js const game = new __helpers.CSSHelp(document).getStyle('#game'); assert.exists(game); ``` -Your `#game` selector should have a `max-width` of `500px`. +O seletor `#game` deve ter um `max-width` com o valor de `500px`. ```js const maxWidth = new __helpers.CSSHelp(document).getStyle('#game')?.getPropertyValue('max-width'); assert.equal(maxWidth, '500px'); ``` -Your `#game` selector should have a `max-height` of `400px`. +O seletor `#game` deve ter um `max-height` com o valor de `400px`. ```js const maxHeight = new __helpers.CSSHelp(document).getStyle('#game')?.getPropertyValue('max-height'); assert.equal(maxHeight, '400px'); ``` -Your `#game` selector should have a `background-color` of `lightgray`. +O elemento `#game` deve ter a `background-color` com o valor de `lightgray`. ```js const background = new __helpers.CSSHelp(document).getStyle('#game')?.getPropertyValue('background-color'); assert.equal(background, 'lightgray'); ``` -Your `#game` selector should have a `color` of `white`. +O seletor `#game` deve ter o atributo `color` com o valor `white`. ```js const color = new __helpers.CSSHelp(document).getStyle('#game')?.getPropertyValue('color'); assert.equal(color, 'white'); ``` -Your `#game` selector should have a `margin` set to `0 auto`. +O seletor `#game` deve ter uma `margin` definida como `0 auto`. ```js const margin = new __helpers.CSSHelp(document).getStyle('#game')?.getPropertyValue('margin'); assert.equal(margin, '0px auto'); ``` -Your `#game` selector should have `10px` of padding on all sides. +O seletor `#game` deve ter `10px` de espaçamento em todos os lados. ```js const padding = new __helpers.CSSHelp(document).getStyle('#game')?.getPropertyValue('padding'); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a24128d5e8af1b47ad1aab.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a24128d5e8af1b47ad1aab.md index a0a17c0808d..f11d1794ed8 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a24128d5e8af1b47ad1aab.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a24128d5e8af1b47ad1aab.md @@ -1,38 +1,38 @@ --- id: 62a24128d5e8af1b47ad1aab -title: Step 11 +title: Passo 11 challengeType: 0 dashedName: step-11 --- # --description-- -Give both your `#controls` and `#stats` elements a `border` of `1px solid black`, a `black` text color, and `5px` of padding. +Dê aos elementos `#controls` e `#stats` uma `border` de `1px solid black`, uma cor de texto `black` e `5px` de preenchimento. # --hints-- -You should have a `#controls, #stats` selector. +Você deve ter um seletor `#controls, #stats`. ```js const selector = new __helpers.CSSHelp(document).getStyle('#controls, #stats'); assert.exists(selector); ``` -Your `#controls, #stats` selector should have a `border` of `1px solid black`. +O seletor `#controls, #stats` deve ter uma `border` de `1px solid black`. ```js const border = new __helpers.CSSHelp(document).getStyle('#controls, #stats')?.getPropertyValue('border'); assert.equal(border, '1px solid black'); ``` -Your `#controls, #stats` selector should have a `color` of `black`. +O seletor `#controls, #stats` deve ter uma `color` de `black`. ```js const color = new __helpers.CSSHelp(document).getStyle('#controls, #stats')?.getPropertyValue('color'); assert.equal(color, 'black'); ``` -Your `#controls, #stats` selector should have `5px` of padding. +O seletor `#controls, #stats` deve ter `5px` de preenchimento. ```js const padding = new __helpers.CSSHelp(document).getStyle('#controls, #stats')?.getPropertyValue('padding'); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a241df03c1f61ce936f5d9.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a241df03c1f61ce936f5d9.md index 7527ce74825..ba9cee91689 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a241df03c1f61ce936f5d9.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a241df03c1f61ce936f5d9.md @@ -1,24 +1,24 @@ --- id: 62a241df03c1f61ce936f5d9 -title: Step 14 +title: Passo 14 challengeType: 0 dashedName: step-14 --- # --description-- -Finally, give your `.stat` elements a `padding-right` of `10px`. +Finalmente, dê aos elementos `.stat` um `padding-right` of `10px`. # --hints-- -You should have a `.stat` selector. +Você deve ter um seletor `.stat`. ```js const stat = new __helpers.CSSHelp(document).getStyle('.stat'); assert.exists(stat); ``` -Your `.stat` selector should have a `padding-right` of `10px`. +O seletor `.stat` deve ter um `padding-right` com o valor de `10px`. ```js const paddingRight = new __helpers.CSSHelp(document).getStyle('.stat')?.getPropertyValue('padding-right'); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a2509ba163e020bb9d84ea.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a2509ba163e020bb9d84ea.md index c65bb85e38f..ac9ab815c9a 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a2509ba163e020bb9d84ea.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a2509ba163e020bb9d84ea.md @@ -1,29 +1,29 @@ --- id: 62a2509ba163e020bb9d84ea -title: Step 15 +title: Passo 15 challengeType: 0 dashedName: step-15 --- # --description-- -Now you can start writing your JavaScript. Begin by creating a `script` element. This element is used to load JavaScript into your HTML file. You should use an opening `` tag. +Agora, você pode começar a escrever o JavaScript. Comece criando um elemento `script`. Este elemento é usado para carregar o JavaScript no arquivo HTML. Você deve usar uma tag de abertura ``. # --hints-- -You should have a `script` element. +Você deve ter apenas um elemento `script`. ```js assert.isAtLeast(document.querySelectorAll('script').length, 2); ``` -Your `script` element should have an opening tag. +O elemento `script` deve ter uma tag de abertura. ```js assert.match(code, //i); ``` -Your `script` element should have a closing tag. +O elemento `script` deve ter uma tag de fechamento. ```js assert.match(code, /<\/script\s*>/i); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a255dae245b52317da824a.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a255dae245b52317da824a.md index 2515e3330ca..e7425d7ab5d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a255dae245b52317da824a.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a255dae245b52317da824a.md @@ -1,27 +1,27 @@ --- id: 62a255dae245b52317da824a -title: Step 16 +title: Passo 16 challengeType: 0 dashedName: step-16 --- # --description-- -One of the most powerful tools is your developer console. Depending on your browser, this might be opened by pressing `F12` or `Ctrl+Shift+I`. You can also click the "Console" button above the preview window to see our built-in console. The developer console will include errors that are produced by your code, but you can also use it to see values of variables in your code, which is helpful for debugging. +Uma das ferramentas mais poderosas é o console do desenvolvedor. Dependendo do navegador, ele pode ser aberto pressionando `F12` ou `Ctrl+Shift+I`. Você também pode clicar no botão "Console" acima da janela de pré-visualização para ver o console embutido. O console do desenvolvedor incluirá erros produzidos pelo código, mas você também pode usá-lo para ver valores de variáveis no código, o que é útil para depuração. -Add a `console.log("Hello World");` line between your `script` tags, then click the "Console" button to open our console, and you should see the text `Hello World` in your console. +Adicione a linha `console.log("Hello World");` entre as tags `script` e, em seguida, clique no botão "Console" para abrir o console, e você deve ver ali o texto `Hello World`. -Note how the line ends with a semi-colon. It is common practice in JavaScript to end your code lines with semi-colons. +Observe como a linha termina com ponto e vírgula. É prática comum em JavaScript encerrar as linhas de código com ponto e vírgula. # --hints-- -You should add a `console.log("Hello World");` line to your code. Don't forget the semi-colon. +Você deve adicionar uma linha `console.log("Hello World");` no código. Não se esqueça do ponto e vírgula. ```js assert.match(code, /console\.log\("Hello World"\);/); ``` -Your `console.log("Hello World");` line should be between your `script` tags. +A linha `console.log("Hello World");` deve estar entre as tags `script`. ```js assert.match(code, /