From 2fbafda16721fd83a2f700a24a129b913691619c Mon Sep 17 00:00:00 2001 From: SomeDer <48731521+SomeDer@users.noreply.github.com> Date: Tue, 5 Nov 2019 02:09:40 -0100 Subject: [PATCH] feat: functional programming spreadsheet (#36873) * Add meta.json for spreadsheet * Add spreadsheet files * Close code tags for tests in 2 files * Add solution section * Add index file * Add javascript-spreadsheet to stringifier * Move index to step * Rename steps in meta.json * Rename step numbers in files * Add index file to proper location * Remove inappropriate files from spreadsheet dir * Fix typo in first step * Fix test sections * Rename files to correct step * Fix broken tests * Add newline between sections * Change challengeType from 1 to 0 * Add missng ) in step-079.md * test -> tests in step-079 * Simplify test in step-103 * Fix step-137 test * Remove last step * Added solutions and adjusted some tests * Fix some challenges * Remove wrong spaces * Fix more tests * Add missing semicolon * Fix more tests * Fix type: lastttwo * Fix all remaining tests --- .../javascript-spreadsheet/index.md | 10 + .../_meta/javascript-spreadsheet/meta.json | 579 ++++++++++++++++++ .../javascript-spreadsheet/step-001.md | 107 ++++ .../javascript-spreadsheet/step-002.md | 111 ++++ .../javascript-spreadsheet/step-003.md | 114 ++++ .../javascript-spreadsheet/step-004.md | 118 ++++ .../javascript-spreadsheet/step-005.md | 125 ++++ .../javascript-spreadsheet/step-006.md | 125 ++++ .../javascript-spreadsheet/step-007.md | 119 ++++ .../javascript-spreadsheet/step-008.md | 112 ++++ .../javascript-spreadsheet/step-009.md | 114 ++++ .../javascript-spreadsheet/step-010.md | 112 ++++ .../javascript-spreadsheet/step-011.md | 113 ++++ .../javascript-spreadsheet/step-012.md | 118 ++++ .../javascript-spreadsheet/step-013.md | 127 ++++ .../javascript-spreadsheet/step-014.md | 123 ++++ .../javascript-spreadsheet/step-015.md | 127 ++++ .../javascript-spreadsheet/step-016.md | 127 ++++ .../javascript-spreadsheet/step-017.md | 128 ++++ .../javascript-spreadsheet/step-018.md | 133 ++++ .../javascript-spreadsheet/step-019.md | 140 +++++ .../javascript-spreadsheet/step-020.md | 135 ++++ .../javascript-spreadsheet/step-021.md | 138 +++++ .../javascript-spreadsheet/step-022.md | 146 +++++ .../javascript-spreadsheet/step-023.md | 140 +++++ .../javascript-spreadsheet/step-024.md | 143 +++++ .../javascript-spreadsheet/step-025.md | 152 +++++ .../javascript-spreadsheet/step-026.md | 154 +++++ .../javascript-spreadsheet/step-027.md | 155 +++++ .../javascript-spreadsheet/step-028.md | 157 +++++ .../javascript-spreadsheet/step-029.md | 159 +++++ .../javascript-spreadsheet/step-030.md | 169 +++++ .../javascript-spreadsheet/step-031.md | 167 +++++ .../javascript-spreadsheet/step-032.md | 164 +++++ .../javascript-spreadsheet/step-033.md | 164 +++++ .../javascript-spreadsheet/step-034.md | 165 +++++ .../javascript-spreadsheet/step-035.md | 169 +++++ .../javascript-spreadsheet/step-036.md | 168 +++++ .../javascript-spreadsheet/step-037.md | 174 ++++++ .../javascript-spreadsheet/step-038.md | 176 ++++++ .../javascript-spreadsheet/step-039.md | 180 ++++++ .../javascript-spreadsheet/step-040.md | 185 ++++++ .../javascript-spreadsheet/step-041.md | 187 ++++++ .../javascript-spreadsheet/step-042.md | 196 ++++++ .../javascript-spreadsheet/step-043.md | 193 ++++++ .../javascript-spreadsheet/step-044.md | 185 ++++++ .../javascript-spreadsheet/step-045.md | 184 ++++++ .../javascript-spreadsheet/step-046.md | 184 ++++++ .../javascript-spreadsheet/step-047.md | 183 ++++++ .../javascript-spreadsheet/step-048.md | 185 ++++++ .../javascript-spreadsheet/step-049.md | 186 ++++++ .../javascript-spreadsheet/step-050.md | 186 ++++++ .../javascript-spreadsheet/step-051.md | 186 ++++++ .../javascript-spreadsheet/step-052.md | 189 ++++++ .../javascript-spreadsheet/step-053.md | 198 ++++++ .../javascript-spreadsheet/step-054.md | 202 ++++++ .../javascript-spreadsheet/step-055.md | 202 ++++++ .../javascript-spreadsheet/step-056.md | 202 ++++++ .../javascript-spreadsheet/step-057.md | 206 +++++++ .../javascript-spreadsheet/step-058.md | 210 +++++++ .../javascript-spreadsheet/step-059.md | 212 +++++++ .../javascript-spreadsheet/step-060.md | 213 +++++++ .../javascript-spreadsheet/step-061.md | 215 +++++++ .../javascript-spreadsheet/step-062.md | 210 +++++++ .../javascript-spreadsheet/step-063.md | 210 +++++++ .../javascript-spreadsheet/step-064.md | 211 +++++++ .../javascript-spreadsheet/step-065.md | 216 +++++++ .../javascript-spreadsheet/step-066.md | 210 +++++++ .../javascript-spreadsheet/step-067.md | 217 +++++++ .../javascript-spreadsheet/step-068.md | 212 +++++++ .../javascript-spreadsheet/step-069.md | 212 +++++++ .../javascript-spreadsheet/step-070.md | 212 +++++++ .../javascript-spreadsheet/step-071.md | 214 +++++++ .../javascript-spreadsheet/step-072.md | 215 +++++++ .../javascript-spreadsheet/step-073.md | 215 +++++++ .../javascript-spreadsheet/step-074.md | 218 +++++++ .../javascript-spreadsheet/step-075.md | 221 +++++++ .../javascript-spreadsheet/step-076.md | 225 +++++++ .../javascript-spreadsheet/step-077.md | 230 +++++++ .../javascript-spreadsheet/step-078.md | 238 +++++++ .../javascript-spreadsheet/step-079.md | 238 +++++++ .../javascript-spreadsheet/step-080.md | 243 ++++++++ .../javascript-spreadsheet/step-081.md | 246 ++++++++ .../javascript-spreadsheet/step-082.md | 256 ++++++++ .../javascript-spreadsheet/step-083.md | 254 ++++++++ .../javascript-spreadsheet/step-084.md | 255 ++++++++ .../javascript-spreadsheet/step-085.md | 256 ++++++++ .../javascript-spreadsheet/step-086.md | 260 ++++++++ .../javascript-spreadsheet/step-087.md | 263 ++++++++ .../javascript-spreadsheet/step-088.md | 266 ++++++++ .../javascript-spreadsheet/step-089.md | 278 +++++++++ .../javascript-spreadsheet/step-090.md | 279 +++++++++ .../javascript-spreadsheet/step-091.md | 284 +++++++++ .../javascript-spreadsheet/step-092.md | 286 +++++++++ .../javascript-spreadsheet/step-093.md | 287 +++++++++ .../javascript-spreadsheet/step-094.md | 291 +++++++++ .../javascript-spreadsheet/step-095.md | 292 +++++++++ .../javascript-spreadsheet/step-096.md | 293 +++++++++ .../javascript-spreadsheet/step-097.md | 300 +++++++++ .../javascript-spreadsheet/step-098.md | 294 +++++++++ .../javascript-spreadsheet/step-099.md | 302 +++++++++ .../javascript-spreadsheet/step-100.md | 298 +++++++++ .../javascript-spreadsheet/step-101.md | 294 +++++++++ .../javascript-spreadsheet/step-102.md | 295 +++++++++ .../javascript-spreadsheet/step-103.md | 295 +++++++++ .../javascript-spreadsheet/step-104.md | 295 +++++++++ .../javascript-spreadsheet/step-105.md | 293 +++++++++ .../javascript-spreadsheet/step-106.md | 296 +++++++++ .../javascript-spreadsheet/step-107.md | 298 +++++++++ .../javascript-spreadsheet/step-108.md | 299 +++++++++ .../javascript-spreadsheet/step-109.md | 300 +++++++++ .../javascript-spreadsheet/step-110.md | 298 +++++++++ .../javascript-spreadsheet/step-111.md | 298 +++++++++ .../javascript-spreadsheet/step-112.md | 299 +++++++++ .../javascript-spreadsheet/step-113.md | 300 +++++++++ .../javascript-spreadsheet/step-114.md | 302 +++++++++ .../javascript-spreadsheet/step-115.md | 306 +++++++++ .../javascript-spreadsheet/step-116.md | 313 ++++++++++ .../javascript-spreadsheet/step-117.md | 318 ++++++++++ .../javascript-spreadsheet/step-118.md | 319 ++++++++++ .../javascript-spreadsheet/step-119.md | 324 ++++++++++ .../javascript-spreadsheet/step-120.md | 318 ++++++++++ .../javascript-spreadsheet/step-121.md | 328 ++++++++++ .../javascript-spreadsheet/step-122.md | 320 ++++++++++ .../javascript-spreadsheet/step-123.md | 329 ++++++++++ .../javascript-spreadsheet/step-124.md | 322 ++++++++++ .../javascript-spreadsheet/step-125.md | 326 ++++++++++ .../javascript-spreadsheet/step-126.md | 335 ++++++++++ .../javascript-spreadsheet/step-127.md | 330 ++++++++++ .../javascript-spreadsheet/step-128.md | 340 ++++++++++ .../javascript-spreadsheet/step-129.md | 345 +++++++++++ .../javascript-spreadsheet/step-130.md | 338 ++++++++++ .../javascript-spreadsheet/step-131.md | 338 ++++++++++ .../javascript-spreadsheet/step-132.md | 341 +++++++++++ .../javascript-spreadsheet/step-133.md | 345 +++++++++++ .../javascript-spreadsheet/step-134.md | 347 +++++++++++ .../javascript-spreadsheet/step-135.md | 350 +++++++++++ .../javascript-spreadsheet/step-136.md | 352 +++++++++++ .../javascript-spreadsheet/step-137.md | 355 +++++++++++ .../javascript-spreadsheet/step-138.md | 351 +++++++++++ .../javascript-spreadsheet/step-139.md | 352 +++++++++++ .../javascript-spreadsheet/step-140.md | 353 +++++++++++ utils/block-nameify.js | 3 +- 143 files changed, 32912 insertions(+), 1 deletion(-) create mode 100644 client/src/pages/learn/javascript-algorithms-and-data-structures/javascript-spreadsheet/index.md create mode 100644 curriculum/challenges/_meta/javascript-spreadsheet/meta.json create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-001.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-002.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-003.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-004.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-005.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-006.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-007.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-008.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-009.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-010.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-011.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-012.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-013.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-014.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-015.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-016.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-017.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-018.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-019.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-020.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-021.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-022.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-023.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-024.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-025.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-026.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-027.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-028.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-029.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-030.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-031.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-032.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-033.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-034.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-035.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-036.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-037.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-038.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-039.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-040.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-041.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-042.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-043.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-044.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-045.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-046.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-047.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-048.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-049.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-050.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-051.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-052.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-053.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-054.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-055.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-056.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-057.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-058.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-059.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-060.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-061.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-062.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-063.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-064.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-065.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-066.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-067.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-068.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-069.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-070.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-071.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-072.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-073.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-074.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-075.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-076.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-077.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-078.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-079.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-080.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-081.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-082.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-083.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-084.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-085.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-086.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-087.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-088.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-089.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-090.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-091.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-092.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-093.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-094.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-095.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-096.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-097.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-098.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-099.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-100.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-101.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-102.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-103.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-104.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-105.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-106.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-107.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-108.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-109.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-110.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-111.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-112.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-113.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-114.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-115.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-116.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-117.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-118.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-119.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-120.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-121.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-122.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-123.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-124.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-125.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-126.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-127.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-128.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-129.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-130.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-131.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-132.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-133.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-134.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-135.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-136.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-137.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-138.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-139.md create mode 100644 curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-140.md diff --git a/client/src/pages/learn/javascript-algorithms-and-data-structures/javascript-spreadsheet/index.md b/client/src/pages/learn/javascript-algorithms-and-data-structures/javascript-spreadsheet/index.md new file mode 100644 index 0000000000..744c7d2c54 --- /dev/null +++ b/client/src/pages/learn/javascript-algorithms-and-data-structures/javascript-spreadsheet/index.md @@ -0,0 +1,10 @@ +--- +title: Introduction to the JavaScript Spreadsheet +block: JavaScript Spreadsheet +superBlock: JavaScript Algorithms and Data Structures +isBeta: true +--- + +## Introduction to the JavaScript Spreadsheet + +This is a test for the new project-based curriculum. diff --git a/curriculum/challenges/_meta/javascript-spreadsheet/meta.json b/curriculum/challenges/_meta/javascript-spreadsheet/meta.json new file mode 100644 index 0000000000..ce19675071 --- /dev/null +++ b/curriculum/challenges/_meta/javascript-spreadsheet/meta.json @@ -0,0 +1,579 @@ +{ + "name": "JavaScript Spreadsheet", + "dashedName": "javascript-spreadsheet", + "order": 12, + "time": "2 hours", + "template": "", + "required": [], + "superBlock": "javascript-algorithms-and-data-structures", + "superOrder": 2, + "isBeta": true, + "challengeOrder": [ + [ + "5d79253297c0ebb149ea9fed", + "Step 001" + ], + [ + "5d7925323be8848dbc58a07a", + "Step 002" + ], + [ + "5d792532f631702ae6d23e11", + "Step 003" + ], + [ + "5d7925329445167ecc2ac9c9", + "Step 004" + ], + [ + "5d792532b07918c3a5904913", + "Step 005" + ], + [ + "5d792533cc8b18b6c133edc7", + "Step 006" + ], + [ + "5d7925337954ed57a565a135", + "Step 007" + ], + [ + "5d79253352e33dd59ec2f6de", + "Step 008" + ], + [ + "5d792533d31e4f7fad33011d", + "Step 009" + ], + [ + "5d792533e7707b9645d7b540", + "Step 010" + ], + [ + "5d79253378595ec568f70ab6", + "Step 011" + ], + [ + "5d7925330918ae4a2f282e7e", + "Step 012" + ], + [ + "5d792533ed00e75d129e1b18", + "Step 013" + ], + [ + "5d792533a5c42fb4d1a4b70d", + "Step 014" + ], + [ + "5d79253358e8f646cbeb2bb0", + "Step 015" + ], + [ + "5d792533bb38fab70b27f527", + "Step 016" + ], + [ + "5d79253386060ed9eb04a070", + "Step 017" + ], + [ + "5d792533717672657b81aa69", + "Step 018" + ], + [ + "5d7925335ab63018dcec11fe", + "Step 019" + ], + [ + "5d7925330f300c342315066d", + "Step 020" + ], + [ + "5d792533aa6443215c9b16bf", + "Step 021" + ], + [ + "5d7925334c5e22586dd72962", + "Step 022" + ], + [ + "5d79253307ecd49e030bdcd1", + "Step 023" + ], + [ + "5d792534257122211d3043af", + "Step 024" + ], + [ + "5d7925346f4f2da6df4354a6", + "Step 025" + ], + [ + "5d792534cac2dbe0a719ea7a", + "Step 026" + ], + [ + "5d792534857332d07ccba3ad", + "Step 027" + ], + [ + "5d792534d586ef495ea9df90", + "Step 028" + ], + [ + "5d79253410532e13d13fe574", + "Step 029" + ], + [ + "5d7925342415527083bd6667", + "Step 030" + ], + [ + "5d792534c3d26890ac1484d4", + "Step 031" + ], + [ + "5d792534b92f3d1cd4410ce3", + "Step 032" + ], + [ + "5d7925341193948dfe6d76b4", + "Step 033" + ], + [ + "5d792534cf81365cfca58794", + "Step 034" + ], + [ + "5d7925348ee084278ff15556", + "Step 035" + ], + [ + "5d7925348a6a41c32f7a4e3e", + "Step 036" + ], + [ + "5d792534408c5be896b0a46e", + "Step 037" + ], + [ + "5d792534f0eda837510e9192", + "Step 038" + ], + [ + "5d7925346b911fce161febaf", + "Step 039" + ], + [ + "5d79253483eada4dd69258eb", + "Step 040" + ], + [ + "5d7925342b2b993ef18cd45f", + "Step 041" + ], + [ + "5d7925341747ad42b12f8e68", + "Step 042" + ], + [ + "5d792535b0b3c198ee3ed6f9", + "Step 043" + ], + [ + "5d7925357a0533eb221b005d", + "Step 044" + ], + [ + "5d792535591db67ee15b4106", + "Step 045" + ], + [ + "5d792535f1f7adf77de5831d", + "Step 046" + ], + [ + "5d7925353d2c505eafd50cd9", + "Step 047" + ], + [ + "5d79253539b5e944ba3e314c", + "Step 048" + ], + [ + "5d792535a4f1cbff7a8b9a0b", + "Step 049" + ], + [ + "5d792535e3304f15a8890162", + "Step 050" + ], + [ + "5d792535a40ea5ac549d6804", + "Step 051" + ], + [ + "5d7925358c220e5b2998909e", + "Step 052" + ], + [ + "5d7925357729e183a49498aa", + "Step 053" + ], + [ + "5d79253555aa652afbb68086", + "Step 054" + ], + [ + "5d79253582be306d339564f6", + "Step 055" + ], + [ + "5d7925352047e5c54882c436", + "Step 056" + ], + [ + "5d79253568e441c0adf9db9f", + "Step 057" + ], + [ + "5d7925356ab117923b80c9cd", + "Step 058" + ], + [ + "5d792535e54a8cd729a0d708", + "Step 059" + ], + [ + "5d7925353b307724a462b06b", + "Step 060" + ], + [ + "5d792536735f71d746ee5d99", + "Step 061" + ], + [ + "5d792536ad340d9dff2e4a96", + "Step 062" + ], + [ + "5d7925369614afd92d01fed5", + "Step 063" + ], + [ + "5d792536504e68254fe02236", + "Step 064" + ], + [ + "5d792536c8d2f0fdfad768fe", + "Step 065" + ], + [ + "5d79253639028b8ec56afcda", + "Step 066" + ], + [ + "5d792536834f2fd93e84944f", + "Step 067" + ], + [ + "5d792536ddff9ea73c90a994", + "Step 068" + ], + [ + "5d7925361596f84067904f7f", + "Step 069" + ], + [ + "5d792536dd8a4daf255488ac", + "Step 070" + ], + [ + "5d792536449c73004f265fb1", + "Step 071" + ], + [ + "5d79253685fc69b8fe60a0d2", + "Step 072" + ], + [ + "5d792536dc6e3ab29525de9e", + "Step 073" + ], + [ + "5d792536cfd0fd893c630abb", + "Step 074" + ], + [ + "5d7925366a5ff428fb483b40", + "Step 075" + ], + [ + "5d7925365d4035eeb2e395fd", + "Step 076" + ], + [ + "5d7925364c106e9aaf05a16f", + "Step 077" + ], + [ + "5d792536970cd8e819cc8a96", + "Step 078" + ], + [ + "5d792536e33baeaa60129e0a", + "Step 079" + ], + [ + "5d7925379e2a488f333e2d43", + "Step 080" + ], + [ + "5d7925379000785f6d8d9af3", + "Step 081" + ], + [ + "5d79253791391b0acddd0ac5", + "Step 082" + ], + [ + "5d7925373104ae5ae83f20a5", + "Step 083" + ], + [ + "5d7925373b7127cfaeb50c26", + "Step 084" + ], + [ + "5d792537cb3a5cd6baca5e1a", + "Step 085" + ], + [ + "5d79253742f3313d55db981f", + "Step 086" + ], + [ + "5d7925379e0180a438ce7f95", + "Step 087" + ], + [ + "5d792537c80984dfa5501b96", + "Step 088" + ], + [ + "5d7925377b54d8a76efb5657", + "Step 089" + ], + [ + "5d7925371398513549bb6395", + "Step 090" + ], + [ + "5d792537ea3eaf302bf2d359", + "Step 91" + ], + [ + "5d792537533b1c7843bfd029", + "Step 092" + ], + [ + "5d792537dc0fe84345d4f19e", + "Step 093" + ], + [ + "5d792537b6cadae0f4b0cda1", + "Step 094" + ], + [ + "5d79253770083fb730c93a93", + "Step 095" + ], + [ + "5d792537fef76b226b63b93b", + "Step 096" + ], + [ + "5d79253760fca25ccbbd8990", + "Step 097" + ], + [ + "5d7925374321824cba309875", + "Step 098" + ], + [ + "5d7925381e8565a5c50ba7f1", + "Step 099" + ], + [ + "5d7925383f1b77db7f1ff59e", + "Step 100" + ], + [ + "5d792538de9fa3f298bcd5f6", + "Step 101" + ], + [ + "5d7925385b74f69642e1fea5", + "Step 102" + ], + [ + "5d7925380ea76d55b2c97d7b", + "Step 103" + ], + [ + "5d792538be4fe331f1a6c008", + "Step 104" + ], + [ + "5d792538d169f33142175b95", + "Step 105" + ], + [ + "5d792538e48b5a2c6e5bbe12", + "Step 106" + ], + [ + "5d7925387f3e9da5ec856dbe", + "Step 107" + ], + [ + "5d79253824ae9b4a6e6f3108", + "Step 108" + ], + [ + "5d7925383f122a279f4c54ad", + "Step 109" + ], + [ + "5d7925387b682e962f209269", + "Step 110" + ], + [ + "5d792538de774217b173288e", + "Step 111" + ], + [ + "5d79253891d93585323d1f3c", + "Step 112" + ], + [ + "5d7925384e34e944ecb4612d", + "Step 113" + ], + [ + "5d792538631844ad0bdfb4c3", + "Step 114" + ], + [ + "5d792538e2a8d20cc580d481", + "Step 115" + ], + [ + "5d792538f5004390d6678554", + "Step 116" + ], + [ + "5d792539dd4fd4c96fd85f7e", + "Step 117" + ], + [ + "5d79253949802f8587c8bbd3", + "Step 118" + ], + [ + "5d7925395888767e9304c082", + "Step 119" + ], + [ + "5d7925393b30099e37a34668", + "Step 120" + ], + [ + "5d7925398157757b23730fdd", + "Step 121" + ], + [ + "5d792539de4b9ac14dd40409", + "Step 122" + ], + [ + "5d792539534f1bf991bb987f", + "Step 123" + ], + [ + "5d7925394089b762f93ffa52", + "Step 124" + ], + [ + "5d792539ec758d45a6900173", + "Step 125" + ], + [ + "5d7925398d525f61a9ff3a79", + "Step 126" + ], + [ + "5d792539a222f385c5c17d2b", + "Step 127" + ], + [ + "5d7925398a7184b41b12a0e0", + "Step 128" + ], + [ + "5d7925399afb905c34730a75", + "Step 129" + ], + [ + "5d792539728d1aa7788e2c9b", + "Step 130" + ], + [ + "5d79253939434a2724c0ec41", + "Step 131" + ], + [ + "5d792539b9e1d3c54d8fe94a", + "Step 132" + ], + [ + "5d792539b2e0bd8f9e8213e4", + "Step 133" + ], + [ + "5d792539239148965a1a59a5", + "Step 134" + ], + [ + "5d792539e1446045d0df6d28", + "Step 135" + ], + [ + "5d79253a2febbb77098730b9", + "Step 136" + ], + [ + "5d79253a98bd9fdf7ce68d0a", + "Step 137" + ], + [ + "5d79253a1e9abf29de64c177", + "Step 138" + ], + [ + "5d79253a8b29d78984369e4b", + "Step 139" + ], + [ + "5d79253ad297a31cbe073718", + "Step 140" + ], + [ + "5d79253a0f968095adfa40f6", + "Step 141" + ] + ], + "helpRoom": "HelpJavaScript", + "fileName": "02-javascript-algorithms-and-data-structures/javascript-spreadsheet.json" +} diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-001.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-001.md new file mode 100644 index 0000000000..3cabe90ba5 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-001.md @@ -0,0 +1,107 @@ +--- +id: 5d79253297c0ebb149ea9fed +title: Step 001 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +In functional programming, we prefer immutable values over mutable values. +Mutable values (declared with var or `let`) can lead to unexpected behaviors and bugs. +Values declared with `const` cannot be reassigned, which makes using them easier because you don't have to keep track of their values. +Start by creating an empty `infixToFunction` object using `const`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constinfixToFunction={}")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-002.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-002.md new file mode 100644 index 0000000000..84587719a6 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-002.md @@ -0,0 +1,111 @@ +--- +id: 5d7925323be8848dbc58a07a +title: Step 002 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Above `infixToFunction`, define an empty function `add` using the `function` keyword. +It should accept two parameters, `x` and `y`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("functionadd(x,y){}")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-003.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-003.md new file mode 100644 index 0000000000..c5abc5b878 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-003.md @@ -0,0 +1,114 @@ +--- +id: 5d792532f631702ae6d23e11 +title: Step 003 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Now return the sum of `x` and `y` using the `return` keyword. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(add(1, 2) === 3 && add(100, 2000) === 2100); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-004.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-004.md new file mode 100644 index 0000000000..e63b56465b --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-004.md @@ -0,0 +1,118 @@ +--- +id: 5d7925329445167ecc2ac9c9 +title: Step 004 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +In JavaScript, functions are first class. +This means that they can be used like any other values - for example, they can be assigned to variables. +Assign `add` to a new variable `addVar`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constaddVar=add")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-005.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-005.md new file mode 100644 index 0000000000..31e92cd1d5 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-005.md @@ -0,0 +1,125 @@ +--- +id: 5d792532b07918c3a5904913 +title: Step 005 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Anonymous functions are functions without names - they are used only once and then forgotten. +The syntax is the same as for normal functions but without the name: + +```js +function(x) { + return x +} +``` + +First, remove the `addVar` definition. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(!code.replace(/\s/g, "").includes("constaddVar=add")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-006.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-006.md new file mode 100644 index 0000000000..9319755bbb --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-006.md @@ -0,0 +1,125 @@ +--- +id: 5d792533cc8b18b6c133edc7 +title: Step 006 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Anonymous functions are often passed as arguments to other functions, but what if you want to call one later? +You can assign anonymous functions to variables and call them with the variable's name: + +```js +const fn = function(x) { + return x; +} + +fn(); +``` + +Assign the anonymous function to the variable `addVar`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constaddVar=function(x,y){returnx+y")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-007.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-007.md new file mode 100644 index 0000000000..7e842a71e4 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-007.md @@ -0,0 +1,119 @@ +--- +id: 5d7925337954ed57a565a135 +title: Step 007 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +This is possible because the anonymous function has been immediately assigned to a value - this is effectively the same as using a named function. +Rewrite `addVar` using ES6's arrow syntax: + +```js +const fn = (x, y) => x; +``` + +Note that the value is returned implicitly. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constaddVar=(x,y)=>x+y")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-008.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-008.md new file mode 100644 index 0000000000..c961bd129e --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-008.md @@ -0,0 +1,112 @@ +--- +id: 5d79253352e33dd59ec2f6de +title: Step 008 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add the key `+` to `infixToFunction` and assign it the value `addVar`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(infixToFunction["+"].toString() === addVar.toString()); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-009.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-009.md new file mode 100644 index 0000000000..ff9a76a8d4 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-009.md @@ -0,0 +1,114 @@ +--- +id: 5d792533d31e4f7fad33011d +title: Step 009 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +In `infixToFunction`, replace `addVar` with `(x, y) => x + y`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, '').match(/\+["']:\(x,y\)=>x\+y/)); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-010.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-010.md new file mode 100644 index 0000000000..ae70cc6866 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-010.md @@ -0,0 +1,112 @@ +--- +id: 5d792533e7707b9645d7b540 +title: Step 010 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Remove the now redundant `addVar` definition. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(typeof addVar === "undefined"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-011.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-011.md new file mode 100644 index 0000000000..1131609af5 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-011.md @@ -0,0 +1,113 @@ +--- +id: 5d79253378595ec568f70ab6 +title: Step 011 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add similar definitions for `-`, `*` and `/` in `infixToFunction`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(infixToFunction["-"](10, 2) === 8 && infixToFunction["*"](10, 10) === 100 && infixToFunction["/"](100, 10) === 10); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-012.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-012.md new file mode 100644 index 0000000000..b8a29bfe4a --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-012.md @@ -0,0 +1,118 @@ +--- +id: 5d7925330918ae4a2f282e7e +title: Step 012 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Use arrow function syntax to define a function `infixEval` which takes `str` and `regex` as arguments and returns `str.replace(regex, "")`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/constinfixEval=\(str,regex\)=>str\.replace\(regex,['"]{2}\)/.test(code.replace(/\s/g, ''))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-013.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-013.md new file mode 100644 index 0000000000..b09735c6d1 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-013.md @@ -0,0 +1,127 @@ +--- +id: 5d792533ed00e75d129e1b18 +title: Step 013 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +`replace` is a higher order function because it can take a function as argument (higher order functions can also return functions). +Pass the `+` function from `infixToFunction` to the `replace` method as the second argument. +This is how you would pass the `-` function: + +```js +str.replace(regex, infixToFunction["-"]) +``` + + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(infixEval("ab", /(a)b/) === "aba"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-014.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-014.md new file mode 100644 index 0000000000..eee39f04af --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-014.md @@ -0,0 +1,123 @@ +--- +id: 5d792533a5c42fb4d1a4b70d +title: Step 014 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Replace the second argument of `str.replace` with an anonymous function, which takes `match`, `arg1`, `fn`, and `arg2`, and returns `infixToFunction["+"]`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes('str.replace(regex,(match,arg1,fn,arg2)=>infixToFunction["+"])')); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-015.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-015.md new file mode 100644 index 0000000000..ee762b92f2 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-015.md @@ -0,0 +1,127 @@ +--- +id: 5d79253358e8f646cbeb2bb0 +title: Step 015 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Change the `"+"` in the call to `infixToFunction` to `fn`. +`fn` is the operator that the user inputs (`+`, `-`, `*` or `/`) - we use `infixToFunction` to get the function that corresponds to it. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes('str.replace(regex,(match,arg1,fn,arg2)=>infixToFunction[fn])')); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-016.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-016.md new file mode 100644 index 0000000000..1a0b8a7003 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-016.md @@ -0,0 +1,127 @@ +--- +id: 5d792533bb38fab70b27f527 +title: Step 016 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +`arg1` and `arg2` are the numbers inputed by the user in a string such as "1+3". +Pass `parseFloat(arg1)` and `parseFloat(arg2)` as the arguments to `infixToFunction[fn]` (remember `infixToFunction[fn]` is a function). + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: const regex = /([0-9.]+)([+-\/*])([0-9.]+)/; assert(infixEval("23+35", regex) === "58" && infixEval("100-20", regex) === "80" && infixEval("10*10", regex) === "100" && infixEval("120/6", regex) === "20"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-017.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-017.md new file mode 100644 index 0000000000..f26ab2409f --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-017.md @@ -0,0 +1,128 @@ +--- +id: 5d79253386060ed9eb04a070 +title: Step 017 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `match` parameter is currently unused, which can lead to unused variable warnings in some linters. +To fix this, prefix or replace it with an underscore (`_`) - both ways signal to the reader and linter that you're aware you don't need this. +Note that a single underscore can only be used once in a function and may conflict with some libraries (Lodash, Undrescore.js). + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("str.replace(regex,(_")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-018.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-018.md new file mode 100644 index 0000000000..ded926730b --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-018.md @@ -0,0 +1,133 @@ +--- +id: 5d792533717672657b81aa69 +title: Step 018 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +When defining an arrow function with a single argument, the parentheses can be omitted: + +```js +const greeting = name => `Hello !`; +``` + +Define a function `highPrecedence` which takes a single argument `str` and returns it. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(highPrecedence("a") === "a"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-019.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-019.md new file mode 100644 index 0000000000..81d9fe5ec5 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-019.md @@ -0,0 +1,140 @@ +--- +id: 5d7925335ab63018dcec11fe +title: Step 019 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Arrow functions can have multiple statements: + +```js +const fn = (x, y) => { + const result = x + y; + return result; // explicit return statement required +}; +``` + +Use this syntax for the `highPrecedence` function. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("highPrecedence=str=>{returnstr")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-020.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-020.md new file mode 100644 index 0000000000..f1e8631d56 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-020.md @@ -0,0 +1,135 @@ +--- +id: 5d7925330f300c342315066d +title: Step 020 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +In `highPrecedence`, define `regex` to be `/([0-9.]+)([*\/])([0-9.]+)/`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("regex=/([0-9.]+)([*\\/])([0-9.]+)/")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-021.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-021.md new file mode 100644 index 0000000000..c15aa5457e --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-021.md @@ -0,0 +1,138 @@ +--- +id: 5d792533aa6443215c9b16bf +title: Step 021 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Now, assign the result of calling `infixEval` with `str` and `regex` to `str2`. +Return `str2`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(highPrecedence("7*6") === "42" && highPrecedence("50/25") === "2"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-022.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-022.md new file mode 100644 index 0000000000..261f3cb233 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-022.md @@ -0,0 +1,146 @@ +--- +id: 5d7925334c5e22586dd72962 +title: Step 022 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The ternary operator has the following syntax: + +```js +const result = condition ? valueIfTrue : valueIfFalse; +const result = 1 === 1 ? 1 : 0; // 1 +const result = 9 > 10 ? "Yes" : "No"; // "No" +``` + +Use this operator to return `str` if `str === str2`, and an empty string (`""`) otherwise. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(highPrecedence("2*2") === "" && highPrecedence("2+2") === "2+2" && code.includes("?")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-023.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-023.md new file mode 100644 index 0000000000..574d437c1e --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-023.md @@ -0,0 +1,140 @@ +--- +id: 5d79253307ecd49e030bdcd1 +title: Step 023 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Recursion is when a function calls itself. +We often use it instead of while/for loops, as loops usually involve mutable state. +Replace the empty string in `highPrecedence` with a call to `highPrecedence` with `str2` as argument. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(highPrecedence("2*2*2") === "8" && highPrecedence("2*2") === "4" && highPrecedence("2+2") === "2+2"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-024.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-024.md new file mode 100644 index 0000000000..817e2236f0 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-024.md @@ -0,0 +1,143 @@ +--- +id: 5d792534257122211d3043af +title: Step 024 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Define an object `spreadsheetFunctions`, with a single key - an empty string (`""`). +The corresponding value should be the function `x => x`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(spreadsheetFunctions[""]("x") === "x"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-025.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-025.md new file mode 100644 index 0000000000..7810c58538 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-025.md @@ -0,0 +1,152 @@ +--- +id: 5d7925346f4f2da6df4354a6 +title: Step 025 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Define an empty function `applyFn` which takes an argument `str`. +Use the curly brace syntax with an anonymous function. +Do not wrap parentheses around the parameter. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constapplyFn=str=>{}")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-026.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-026.md new file mode 100644 index 0000000000..02a7ed6a10 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-026.md @@ -0,0 +1,154 @@ +--- +id: 5d792534cac2dbe0a719ea7a +title: Step 026 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Set `noHigh` to `highPrecedence(str)` in `applyFn`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constapplyFn=str=>{constnoHigh=highPrecedence(str)")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-027.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-027.md new file mode 100644 index 0000000000..bd9352d8da --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-027.md @@ -0,0 +1,155 @@ +--- +id: 5d792534857332d07ccba3ad +title: Step 027 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Set `infix` to `/([0-9.]+)([+-])([0-9.]+)/` in `applyFn`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constapplyFn=str=>{constnoHigh=highPrecedence(str);constinfix=/([0-9.]+)([+-])([0-9.]+)/")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-028.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-028.md new file mode 100644 index 0000000000..5113f05501 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-028.md @@ -0,0 +1,157 @@ +--- +id: 5d792534d586ef495ea9df90 +title: Step 028 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Set `str2` to `infixEval(noHigh, infix)`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constapplyFn=str=>{constnoHigh=highPrecedence(str);constinfix=/([0-9.]+)([+-])([0-9.]+)/;conststr2=infixEval(noHigh,infix)")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-029.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-029.md new file mode 100644 index 0000000000..8020836a55 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-029.md @@ -0,0 +1,159 @@ +--- +id: 5d79253410532e13d13fe574 +title: Step 029 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Set `regex` to `/([a-z]*)\(([0-9., ]*)\)(?!.*\()/i` in `applyFn`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(applyFn.toString().replace(/\s/g, '').includes('varregex=/([a-z]*)\\(([0-9.,]*)\\)(?!.*\\()/i')); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-030.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-030.md new file mode 100644 index 0000000000..275c302e52 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-030.md @@ -0,0 +1,169 @@ +--- +id: 5d7925342415527083bd6667 +title: Step 030 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `split` method returns an array of strings from a larger string by using its argument to determine where to make each split: + +```js +"a b c".split(" "); // ["a", "b", "c"]; +``` + +Add a function `toNumberList` (inside `applyFn`) which takes an argument `args` and splits it by commas. +Return `toNumberList`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(JSON.stringify(applyFn("")("foo,baz,bar")) === '["foo","baz","bar"]'); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-031.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-031.md new file mode 100644 index 0000000000..3cf5516247 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-031.md @@ -0,0 +1,167 @@ +--- +id: 5d792534c3d26890ac1484d4 +title: Step 031 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `map` method takes a function and for each element of an array, it passes the element to the function and replace the element with the return value: + +```js +[1, 2, 3].map(x => x + 1); // [2, 3, 4] +``` + +In `toNumberList`, chain the `map` method to `args.split(",")` and pass it `parseFloat` to parse each element of the array into a number. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes('consttoNumberList=args=>args.split(",").map(parseFloat)')); + +``` + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-032.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-032.md new file mode 100644 index 0000000000..5b564464b5 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-032.md @@ -0,0 +1,164 @@ +--- +id: 5d792534b92f3d1cd4410ce3 +title: Step 032 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Define a new function `applyFunction` (inside `applyFn`). +It should take two arguments: `fn` and `args`, and should return `spreadsheetFunctions`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes('consttoNumberList=args=>args.split(",").map(parseFloat);constapplyFunction=(fn,args)=>spreadsheetFunctions')); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-033.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-033.md new file mode 100644 index 0000000000..e8f0af41ff --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-033.md @@ -0,0 +1,164 @@ +--- +id: 5d7925341193948dfe6d76b4 +title: Step 033 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Now, instead of returning `spreadsheetFunctions`, use bracket notation and `fn.toLowerCase()` to get a specific function from `spreadsheetFunctions`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes('consttoNumberList=args=>args.split(",").map(parseFloat);constapplyFunction=(fn,args)=>spreadsheetFunctions[fn.toLowerCase()]')); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-034.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-034.md new file mode 100644 index 0000000000..082f9877b0 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-034.md @@ -0,0 +1,165 @@ +--- +id: 5d792534cf81365cfca58794 +title: Step 034 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Apply `toNumberList(args)` to `spreadsheetFunctions[fn.toLowerCase()]`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes('consttoNumberList=args=>args.split(",").map(parseFloat);constapplyFunction=(fn,args)=>spreadsheetFunctions[fn.toLowerCase()](toNumberList(args))')); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-035.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-035.md new file mode 100644 index 0000000000..7c03e0425b --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-035.md @@ -0,0 +1,169 @@ +--- +id: 5d7925348ee084278ff15556 +title: Step 035 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Note that `applyFunction` can access `toNumberList` from outside of itself. +This is called lexical scoping - inner functions can access variables from outer functions. +Now return `str2.replace(regex, "")` at the end of `applyFn`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(applyFn("2*2fn(1, 2, 3.3)") === "4"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-036.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-036.md new file mode 100644 index 0000000000..1b71d656d7 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-036.md @@ -0,0 +1,168 @@ +--- +id: 5d7925348a6a41c32f7a4e3e +title: Step 036 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Replace the `""` in `str2.replace(regex, "")` with a function which takes `match`, `fn` and `args` as arguments and returns `spreadsheetFunctions`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("returnstr2.replace(regex,(match,fn,args)=>spreadsheetFunctions)")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-037.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-037.md new file mode 100644 index 0000000000..1057ca4072 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-037.md @@ -0,0 +1,174 @@ +--- +id: 5d792534408c5be896b0a46e +title: Step 037 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `hasOwnProperty` method checks if a key exists in an object. +So `spreadsheetFunctions.hasOwnProperty("")` would return `true`, but replacing `""` with anything else would make it return `false`. +Chain `hasOwnProperty` to `spreadsheetFunctions` to check if the `fn.toLowerCase()` key exists in `spreadsheetFunctions`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("returnstr2.replace(regex,(match,fn,args)=>spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()))")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-038.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-038.md new file mode 100644 index 0000000000..6296bf7432 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-038.md @@ -0,0 +1,176 @@ +--- +id: 5d792534f0eda837510e9192 +title: Step 038 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Now use the ternary operator in the last line to return `applyFunction(fn, args)` if the statement is true, and `match` otherwise. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(applyFn("2+2*2") === "6" && applyFn("(2+2)*2") === "4*2"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-039.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-039.md new file mode 100644 index 0000000000..cd28c8da72 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-039.md @@ -0,0 +1,180 @@ +--- +id: 5d7925346b911fce161febaf +title: Step 039 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Now define an empty function `range` which takes `start` and `end` as arguments (define it in the global scope). + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constrange=(start,end)=>")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-040.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-040.md new file mode 100644 index 0000000000..e990234dca --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-040.md @@ -0,0 +1,185 @@ +--- +id: 5d79253483eada4dd69258eb +title: Step 040 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +`range` should set `arr` to `[start]` and should then return `arr`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constarr=[start]") && JSON.stringify(range(1)) === "[1]"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-041.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-041.md new file mode 100644 index 0000000000..436839a2f3 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-041.md @@ -0,0 +1,187 @@ +--- +id: 5d7925342b2b993ef18cd45f +title: Step 041 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +After declaring `arr`, but before returning it, `range` should use the `push` method to add `end` onto `arr`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(JSON.stringify(range(1, 2)) === "[1,2]" && code.includes("push")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-042.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-042.md new file mode 100644 index 0000000000..745085c620 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-042.md @@ -0,0 +1,196 @@ +--- +id: 5d7925341747ad42b12f8e68 +title: Step 042 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +This is still valid because we're modifying `arr` in place instead of reassigning to it (which is invalid with the `const` keyword). +But doing this still modifies state, and we don't want to do that in functional programming. +The `concat` method returns a new array instead of modifying an existing one: + +```js +[1,2,3].concat(4); // [1, 2, 3, 4] +[1,2,3].concat(4, 5); // [1, 2, 3, 4, 5] +``` + +Use `concat` instead of `push` to return the result of adding `end` to `arr`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(JSON.stringify(range(1,2)) === "[1,2]" && code.includes("concat") && !(code.includes("push"))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-043.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-043.md new file mode 100644 index 0000000000..cf17379149 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-043.md @@ -0,0 +1,193 @@ +--- +id: 5d792535b0b3c198ee3ed6f9 +title: Step 043 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `concat` method can also accept arrays: + +```js +[1,2,3].concat([4, 5]); // [1, 2, 3, 4, 5] +[1,2,3].concat([4, 5], [6, 7]); // [1, 2, 3, 4, 5, 6, 7] +``` + +Use this form of `concat` by passing an array with just `end` to it: `arr.concat([end])`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("returnarr.concat([end])")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-044.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-044.md new file mode 100644 index 0000000000..85a373345c --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-044.md @@ -0,0 +1,185 @@ +--- +id: 5d7925357a0533eb221b005d +title: Step 044 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Replace the call to `arr` in `arr.concat([end])` with `[start]` and remove the `arr` variable and its definition. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(!(code.includes("arr")) && code.replace(/\s/g, "").includes("[start].concat([end])")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-045.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-045.md new file mode 100644 index 0000000000..1ef5a24e5d --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-045.md @@ -0,0 +1,184 @@ +--- +id: 5d792535591db67ee15b4106 +title: Step 045 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Use the ternary operator to return `[]` if `start > end` and `[start].concat([end])` otherwise. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(JSON.stringify(range(3, 2)) === "[]" && JSON.stringify(range(1, 3)) === "[1,3]"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-046.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-046.md new file mode 100644 index 0000000000..cb0f782869 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-046.md @@ -0,0 +1,184 @@ +--- +id: 5d792535f1f7adf77de5831d +title: Step 046 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Replace `[end]` with a recursive call to `range`: `[start].concat(range(start + 1, end))` + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(JSON.stringify(range(1, 5)) === "[1,2,3,4,5]"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-047.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-047.md new file mode 100644 index 0000000000..66de2b307f --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-047.md @@ -0,0 +1,183 @@ +--- +id: 5d7925353d2c505eafd50cd9 +title: Step 047 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Remove the curly braces and `return` keyword from `range`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constrange=(start,end)=>start>end?[]:[start].concat(range(start+1,end))")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-048.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-048.md new file mode 100644 index 0000000000..6a7218bc32 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-048.md @@ -0,0 +1,185 @@ +--- +id: 5d79253539b5e944ba3e314c +title: Step 048 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Define a function `charRange` which takes `start` and `end` as arguments. +It should return `start`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constcharRange=(start,end)=>start")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-049.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-049.md new file mode 100644 index 0000000000..488adb6b54 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-049.md @@ -0,0 +1,186 @@ +--- +id: 5d792535a4f1cbff7a8b9a0b +title: Step 049 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Make `charRange` return `range(start, end)`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(JSON.stringify(charRange(1,5)) === "[1,2,3,4,5]"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-050.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-050.md new file mode 100644 index 0000000000..0e36022ee6 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-050.md @@ -0,0 +1,186 @@ +--- +id: 5d792535e3304f15a8890162 +title: Step 050 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Use the `charCodeAt(0)` method on `start` and `end` in `charRange`, like this: `start.charCodeAt(0)`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(JSON.stringify(charRange("A", "C")) === "[65,66,67]"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-051.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-051.md new file mode 100644 index 0000000000..a63b6b3b19 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-051.md @@ -0,0 +1,186 @@ +--- +id: 5d792535a40ea5ac549d6804 +title: Step 051 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Chain `map` onto `range(start.charCodeAt(0), end.charCodeAt(0))`, with `x => x` as the argument. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("range(start.charCodeAt(0),end.charCodeAt(0)).map(x=>x)")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-052.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-052.md new file mode 100644 index 0000000000..e2ea0b449b --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-052.md @@ -0,0 +1,189 @@ +--- +id: 5d7925358c220e5b2998909e +title: Step 052 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Now, pass `x` to `String.fromCharCode` in the arrow function. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(JSON.stringify(charRange("A", "C")) === '["A","B","C"]'); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-053.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-053.md new file mode 100644 index 0000000000..32cdcd2944 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-053.md @@ -0,0 +1,198 @@ +--- +id: 5d7925357729e183a49498aa +title: Step 053 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Create a new function `evalFormula` which takes a single argument, `x`. +Set `/([A-J])([1-9][0-9]?):([A-J])([1-9][0-9]?)/gi` to a variable named `rangeRegex`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constevalFormula=x=>{constrangeRegex=/([A-J])([1-9][0-9]?):([A-J])([1-9][0-9]?)/gi")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-054.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-054.md new file mode 100644 index 0000000000..c4b2db58c4 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-054.md @@ -0,0 +1,202 @@ +--- +id: 5d79253555aa652afbb68086 +title: Step 054 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Define a function `rangeFromString` in `evalFormula` which takes `n1` and `n2` as arguments and returns `n1`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/evalFormula.*constrangeFromString=\(n1,n2\)=>n1/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-055.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-055.md new file mode 100644 index 0000000000..87b548d812 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-055.md @@ -0,0 +1,202 @@ +--- +id: 5d79253582be306d339564f6 +title: Step 055 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Replace the `n1` return value in `rangeFromString` with `range(n1, n2)`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/evalFormula.*constrangeFromString=\(n1,n2\)=>range\(n1,n2\)/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-056.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-056.md new file mode 100644 index 0000000000..02886e4939 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-056.md @@ -0,0 +1,202 @@ +--- +id: 5d7925352047e5c54882c436 +title: Step 056 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +As `n1` and `n2` are actually strings, replace `n1` and `n2` with `parseInt(n1)` and `parseInt(n2)`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/evalFormula.*constrangeFromString=\(n1,n2\)=>range\(parseInt\(n1\),parseInt\(n2\)\)/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-057.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-057.md new file mode 100644 index 0000000000..9f54a2c8a3 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-057.md @@ -0,0 +1,206 @@ +--- +id: 5d79253568e441c0adf9db9f +title: Step 057 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Now define a function `elemValue`, which takes an argument `n` and returns `n`. +Use the curly brace arrow function syntax. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/evalFormula.*constelemValue=n=>\{returnn;?\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-058.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-058.md new file mode 100644 index 0000000000..0bf53e82be --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-058.md @@ -0,0 +1,210 @@ +--- +id: 5d7925356ab117923b80c9cd +title: Step 058 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Inside `elemValue`, define `fn` to be a function which takes `c` as argument and returns `document.getElementById(c + n).value`. +Return `fn` instead of `n`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/elemValue.*constfn=\(?c\)?=>document\.getElementById\(c\+n\)\.value;?returnfn;?\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-059.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-059.md new file mode 100644 index 0000000000..47f4c0e946 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-059.md @@ -0,0 +1,212 @@ +--- +id: 5d792535e54a8cd729a0d708 +title: Step 059 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Now define `fn` to be `elemValue("1")` (inside `evalFormula` but outside `elemValue`). +As `elemValue` returns a function, `fn` is also a function. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/elemValue.*constfn=elemValue\(['"]1['"]\);?\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-060.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-060.md new file mode 100644 index 0000000000..c03f691655 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-060.md @@ -0,0 +1,213 @@ +--- +id: 5d7925353b307724a462b06b +title: Step 060 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Finally, return `fn("A")`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/elemValue.*constfn=elemValue\(['"]1['"]\);?returnfn\(['"]A['"]\);?\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-061.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-061.md new file mode 100644 index 0000000000..77521fad01 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-061.md @@ -0,0 +1,215 @@ +--- +id: 5d792536735f71d746ee5d99 +title: Step 061 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +You might think that this wouldn't work because `fn` wouldn't have access to `n` after `elemValue` has finished executing. +However, this works because of closures - functions have access to all variables declared at their time of creation. +Inside `elemValue`, remove the variable `fn` and its definition, and replace `return fn` with `return c => document.getElementById(c + n).value`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constelemValue=n=>{returnc=>document.getElementById(c+n).value")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-062.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-062.md new file mode 100644 index 0000000000..06a5720726 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-062.md @@ -0,0 +1,210 @@ +--- +id: 5d792536ad340d9dff2e4a96 +title: Step 062 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Now, remove the curly braces and return statement. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/constelemValue=n=>\(?c=>document\.getElementById\(c\+n\)\.value/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-063.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-063.md new file mode 100644 index 0000000000..dcaa67e7b5 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-063.md @@ -0,0 +1,210 @@ +--- +id: 5d7925369614afd92d01fed5 +title: Step 063 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +You also don't need the parentheses in `elemValue` - it's parsed this way automatically. +Remove them. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/constelemValue=n=>c=>document\.getElementById\(c\+n\)\.value/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-064.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-064.md new file mode 100644 index 0000000000..0251497e8b --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-064.md @@ -0,0 +1,211 @@ +--- +id: 5d792536504e68254fe02236 +title: Step 064 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The technique we just used is called currying - instead of taking multiple arguments, a function takes a single argument and return another function, which also takes a single argument. +Define a new curried function, `addChars`, and set it equal to `c1 => c2 => c1 + c2`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constaddChars=c1=>c2=>c1+c2")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-065.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-065.md new file mode 100644 index 0000000000..8257222979 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-065.md @@ -0,0 +1,216 @@ +--- +id: 5d792536c8d2f0fdfad768fe +title: Step 065 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +You can add more arguments by simply adding another arrow with another argument name: + +```js +const manyArguments = a => b => c => d => [a, b, c, d] +``` + +Add another argument to `addChars` and add it to the sum: `c1 => c2 => n => c1 + c2 + n`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constaddChars=c1=>c2=>n=>c1+c2+n")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-066.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-066.md new file mode 100644 index 0000000000..506b927bb5 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-066.md @@ -0,0 +1,210 @@ +--- +id: 5d79253639028b8ec56afcda +title: Step 066 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Replace the body of `addChars`, so that instead of adding the arguments, it returns a `charRange` between the first two arguments: `c1 => c2 => n => charRange(c1, c2)`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constaddChars=c1=>c2=>n=>charRange(c1,c2)")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-067.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-067.md new file mode 100644 index 0000000000..f48c7d545a --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-067.md @@ -0,0 +1,217 @@ +--- +id: 5d792536834f2fd93e84944f +title: Step 067 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +You call curried functions like this: + +```js +const result = add(1)(2); +``` + +Use `map` on the `charRange` in `addChars`, passing in `x => elemValue(n)(x)` as the argument. + + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constaddChars=c1=>c2=>n=>charRange(c1,c2).map(x=>elemValue(n)(x))")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-068.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-068.md new file mode 100644 index 0000000000..9f5f430e3a --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-068.md @@ -0,0 +1,212 @@ +--- +id: 5d792536ddff9ea73c90a994 +title: Step 068 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +However, you don't need an arrow function. +As `elemValue(n)` is a function, you can pass it to `map` directly. +Change `x => elemValue(n)(x)` to `elemValue(n)`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constaddChars=c1=>c2=>n=>charRange(c1,c2).map(elemValue(n))")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-069.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-069.md new file mode 100644 index 0000000000..cb52eca0b2 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-069.md @@ -0,0 +1,212 @@ +--- +id: 5d7925361596f84067904f7f +title: Step 069 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Remove the `fn` declaration and return statement. +Set `varRangeExpanded` to the result of using the `replace` method on `x`, with `rangeRegex` as the first argument and `""` as the second argument. +Then, return it. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(!(code.includes("const fn")) && code.includes("varRangeExpanded") && evalFormula("A1:J133") === "3"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-070.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-070.md new file mode 100644 index 0000000000..14e5be503f --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-070.md @@ -0,0 +1,212 @@ +--- +id: 5d792536dd8a4daf255488ac +title: Step 070 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Replace the `""` in `varRangeExpanded` with a function, which takes `match`, `c1`, `n1`, `c2` and `n2` as arguments, and returns `n1`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes('constvarRangeExpanded=x.replace(rangeRegex,(match,c1,n1,c2,n2)=>n1)')); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-071.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-071.md new file mode 100644 index 0000000000..efe7b7e420 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-071.md @@ -0,0 +1,214 @@ +--- +id: 5d792536449c73004f265fb1 +title: Step 071 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Replace the `n1` return value in `varRangeExpanded` with `rangeFromString(n1, n2)`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes('constvarRangeExpanded=x.replace(rangeRegex,(match,c1,n1,c2,n2)=>rangeFromString(n1,n2))')); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-072.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-072.md new file mode 100644 index 0000000000..3d0a4e139d --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-072.md @@ -0,0 +1,215 @@ +--- +id: 5d79253685fc69b8fe60a0d2 +title: Step 072 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Chain the `map` method to `rangeFromString(n1, n2)` and pass it `addChars(c1)(c2)` as an argument. +This returns an `addChars` function, which has `c1` and `c2` (the characters) preset, and only needs a number (`n`) to be passed to it (which we get from the `rangeFromString` array). + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes('constvarRangeExpanded=x.replace(rangeRegex,(match,c1,n1,c2,n2)=>rangeFromString(n1,n2).map(addChars(c1)(c2)))')); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-073.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-073.md new file mode 100644 index 0000000000..776a4d2a2b --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-073.md @@ -0,0 +1,215 @@ +--- +id: 5d792536dc6e3ab29525de9e +title: Step 073 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The function in `varRangeExpanded` contains an unused argument. +Replace or prefix it with an underscore. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constvarRangeExpanded=x.replace(rangeRegex,(_")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-074.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-074.md new file mode 100644 index 0000000000..196a31be27 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-074.md @@ -0,0 +1,218 @@ +--- +id: 5d792536cfd0fd893c630abb +title: Step 074 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Set `varRegex` to `/[A-J][1-9][0-9]?/gi`. +Then set `varExpanded` to the result of replacing `varRegex` with an empty string in `varRangeExpanded`. +Return `varExpanded`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.includes("varRegex") && code.includes("varExpanded") && evalFormula("aC12bc") === "abc"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-075.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-075.md new file mode 100644 index 0000000000..7b8b765c86 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-075.md @@ -0,0 +1,221 @@ +--- +id: 5d7925366a5ff428fb483b40 +title: Step 075 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Replace the `""` in `varExpanded` with `match => document.getElementById(match.toUpperCase()).value`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constvarExpanded=varRangeExpanded.replace(varRegex,match=>document.getElementById(match.toUpperCase()).value)")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-076.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-076.md new file mode 100644 index 0000000000..417b413e65 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-076.md @@ -0,0 +1,225 @@ +--- +id: 5d7925365d4035eeb2e395fd +title: Step 076 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Set `functionExpanded` to `applyFn(varExpanded)` in `evalFormula`. +Return `functionExpanded`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.includes("functionExpanded") && applyFn("2+2") === "4"); +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-077.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-077.md new file mode 100644 index 0000000000..0511cfa1e2 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-077.md @@ -0,0 +1,230 @@ +--- +id: 5d7925364c106e9aaf05a16f +title: Step 077 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +`evalFormula` should return the value passed to it if this value remained unchanged. +Otherwise, it should call itself with the latest value. +Use the ternary operator in the last line of `evalFormula` to return `functionExpanded` if `x === functionExpanded` and `evalFormula(functionExpanded)` otherwise. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(evalFormula("(2+2)*2") === "8") + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-078.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-078.md new file mode 100644 index 0000000000..9d42645c09 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-078.md @@ -0,0 +1,238 @@ +--- +id: 5d792536970cd8e819cc8a96 +title: Step 078 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +You can define arrow functions without arguments: + +```js +const two = () => 2; +``` + +Define an empty arrow function without arguments and assign it to `window.onload`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("window.onload=()=>")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-079.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-079.md new file mode 100644 index 0000000000..8b5d61e539 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-079.md @@ -0,0 +1,238 @@ +--- +id: 5d792536e33baeaa60129e0a +title: Step 079 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +In `window.onload`, assign `document.getElementById("container")` to `container`. +Also assign `charRange("A", "J")` to `letters`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/window\.onload=\(\)=>\{constcontainer=document\.getElementById\(["']container["']\);?constletters=charRange\(["']A["'],["']J["']\);?\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-080.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-080.md new file mode 100644 index 0000000000..3cab367951 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-080.md @@ -0,0 +1,243 @@ +--- +id: 5d7925379e2a488f333e2d43 +title: Step 080 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Now define a function `createLabel` which takes an argument `name` and has an empty body. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/window\.onload[\s\S]*constcreateLabel=\(?name\)?=>\{\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-081.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-081.md new file mode 100644 index 0000000000..d851159f6a --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-081.md @@ -0,0 +1,246 @@ +--- +id: 5d7925379000785f6d8d9af3 +title: Step 081 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Inside `createLabel`, assign `document.createElement("div")` to `label`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/window\.onload[\s\S]*constcreateLabel=\(?name\)?=>\{constlabel=document\.createElement\(["']div["']\);?\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-082.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-082.md new file mode 100644 index 0000000000..c9fe214a47 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-082.md @@ -0,0 +1,256 @@ +--- +id: 5d79253791391b0acddd0ac5 +title: Step 082 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add the following code to `createLabel`: + +```js +label.className = "label"; +label.textContent = name; +container.appendChild(label); +``` + + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/window\.onload[\s\S]*constcreateLabel=\(?name\)?=>\{constlabel=document\.createElement\(["']div["']\);?label\.className=["']label["'];?label\.textContent=name;?container\.appendChild\(label\);?\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-083.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-083.md new file mode 100644 index 0000000000..e856040901 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-083.md @@ -0,0 +1,254 @@ +--- +id: 5d7925373104ae5ae83f20a5 +title: Step 083 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `forEach` method takes a function and calls it with each element of the array. +Chain `forEach` to `letters` and pass it the `createLabel` function to create a label for each of the letters. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("letters.forEach(createLabel)")) + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-084.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-084.md new file mode 100644 index 0000000000..1c0bb1463c --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-084.md @@ -0,0 +1,255 @@ +--- +id: 5d7925373b7127cfaeb50c26 +title: Step 084 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add `range(1, 99)` to the end of `window.onload` (the result will be discarded for now). + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/window\.onload[\s\S]*range\(1,99\);?\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-085.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-085.md new file mode 100644 index 0000000000..7763754592 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-085.md @@ -0,0 +1,256 @@ +--- +id: 5d792537cb3a5cd6baca5e1a +title: Step 085 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Chain `forEach` onto `range(1, 99)`, passing in `createLabel` as an argument. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/window\.onload[\s\S]*range\(1,99\)\.forEach\(createLabel\);?\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-086.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-086.md new file mode 100644 index 0000000000..2aae356e48 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-086.md @@ -0,0 +1,260 @@ +--- +id: 5d79253742f3313d55db981f +title: Step 086 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Replace `createLabel` with an arrow function with a block body. +This would allow us to add more statements. +The arrow function should take an argument `x`, and call `createLabel(x)`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/window\.onload[\s\S]*range\(1,99\)\.forEach\(\(?x\)?=>\{createLabel\(x\);?\}\);?\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-087.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-087.md new file mode 100644 index 0000000000..5393c37217 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-087.md @@ -0,0 +1,263 @@ +--- +id: 5d7925379e0180a438ce7f95 +title: Step 087 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Inside the `range` `forEach`, use the `forEach` method on `letters`, passing in a function with argument `x` and an empty body. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/window\.onload.*range\(1,99\)\.forEach\(\(?x\)?=>\{createLabel\(x\);?letters\.forEach\(\(?y\)?=>\{\}\);?\}\);?\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-088.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-088.md new file mode 100644 index 0000000000..58b77df1a3 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-088.md @@ -0,0 +1,266 @@ +--- +id: 5d792537c80984dfa5501b96 +title: Step 088 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Inside `letters.forEach`, assign `document.createElement("input")` to `input`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/window\.onload[\s\S]*range\(1,99\)\.forEach\(\(?x\)?=>\{createLabel\(x\);?letters\.forEach\(\(?y\)?=>\{constinput=document\.createElement\(["']input["']\);?\}\);?\}\);?\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-089.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-089.md new file mode 100644 index 0000000000..45c7ce3b6b --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-089.md @@ -0,0 +1,278 @@ +--- +id: 5d7925377b54d8a76efb5657 +title: Step 089 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add the following code to `letters.forEach`: + +```js +input.type = "text"; +input.id = y + x; +input.onchange = update; +container.appendChild(input); +``` + + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/window\.onload[\s\S]*range\(1,99\)\.forEach\(\(?x\)?=>\{createLabel\(x\);?letters\.forEach\(\(?y\)?=>\{constinput=document\.createElement\(["']input["']\);?input\.type=["']text["'];?input\.id=y\+x;?input\.onchange=update;?container\.appendChild\(input\);?\}\);?\}\);?\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-090.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-090.md new file mode 100644 index 0000000000..16c7bd65ff --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-090.md @@ -0,0 +1,279 @@ +--- +id: 5d7925371398513549bb6395 +title: Step 090 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +In the global scope, define a function called `update` which takes `event` as argument. +It should define a variable, `element`, setting it to `event.target`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/constupdate=\(?event\)?=>\{?constelement=event\.target;?\}?/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-091.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-091.md new file mode 100644 index 0000000000..dee146da8d --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-091.md @@ -0,0 +1,284 @@ +--- +id: 5d792537ea3eaf302bf2d359 +title: Step 091 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Now set `value` to `element.value.replace(/\s/g, "")`. +This removes all whitespace from `element` so that we can ignore it. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/constupdate=\(?event\)?=>\{constelement=event\.target;?constvalue=element\.value\.replace\(\/\\s\/g,["']{2}\);?\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-092.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-092.md new file mode 100644 index 0000000000..a8f92e8aba --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-092.md @@ -0,0 +1,286 @@ +--- +id: 5d792537533b1c7843bfd029 +title: Step 092 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `includes` method works on a string and checks if the argument is its substring. +Add an empty if statement to `update` which executes if `element.id` is **not** a substring of `value`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/constupdate=\(?event\)?=>\{constelement=event\.target;?constvalue=element\.value\.replace\(\/\\s\/g,["']{2}\);?if\(!\(?value\.includes\(element\.id\)\)?\)\{\}\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-093.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-093.md new file mode 100644 index 0000000000..a826887ca1 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-093.md @@ -0,0 +1,287 @@ +--- +id: 5d792537dc0fe84345d4f19e +title: Step 093 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add another condition to the if statement so that it only executes if the first character of `value` is `=`. +Do this by adding `&& value[0] === "="` to the if statement. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/constupdate=\(?event\)?=>\{constelement=event\.target;?constvalue=element\.value\.replace\(\/\\s\/g,["']{2}\);?if\(!\(?value\.includes\(element\.id\)\)?&&value\[0\]===["']=["']\)\{\}\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-094.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-094.md new file mode 100644 index 0000000000..32709cb838 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-094.md @@ -0,0 +1,291 @@ +--- +id: 5d792537b6cadae0f4b0cda1 +title: Step 094 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `slice` method takes two arguments. +It extracts characters from the string from the index specified by the first argument up to (but not including) the second argument. +The index starts at 0. +Use the `slice` method to log the first two letters of `value` to the console. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("console.log(value.slice(0,2))")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-095.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-095.md new file mode 100644 index 0000000000..ad73a23185 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-095.md @@ -0,0 +1,292 @@ +--- +id: 5d79253770083fb730c93a93 +title: Step 095 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +You don't have to specify the second argument in `slice`. +If you don't, then `slice` will extract from the first argument to the end of the string. +Change the call to `slice` to log all characters except the first instead. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("console.log(value.slice(1))")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-096.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-096.md new file mode 100644 index 0000000000..b761db6bb8 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-096.md @@ -0,0 +1,293 @@ +--- +id: 5d792537fef76b226b63b93b +title: Step 096 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Now change the if statement to set `element.value` to the result of passing `value.slice(1)` to `evalFormula`. +There is no need to use `const` because we're modifying `element.value`, not declaring it. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/constupdate=\(?event\)?=>\{constelement=event\.target;?constvalue=element\.value\.replace\(\/\\s\/g,["']{2}\);?if\(!\(?value\.includes\(element\.id\)\)?&&value\[0\]===["']=["']\)\{element\.value=evalFormula\(value\.slice\(1\)\);?\}\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-097.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-097.md new file mode 100644 index 0000000000..b85414591e --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-097.md @@ -0,0 +1,300 @@ +--- +id: 5d79253760fca25ccbbd8990 +title: Step 097 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The array destructuring syntax can be used to extract values from arrays: + +```js +const [x, y] = [1, 2]; // in variables +const fn = ([x, y]) => x + y // in functions +``` + +Use this syntax to define a function `random` in `spreadsheetFunctions` which takes the array `[x, y]` and returns `x`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/["']?random["']?:\(\[x,y\]\)=>x/.test(code.replace(/\s/g, "")) && spreadsheetFunctions["random"]([1, 2]) === 1); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-098.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-098.md new file mode 100644 index 0000000000..3507f805e1 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-098.md @@ -0,0 +1,294 @@ +--- +id: 5d7925374321824cba309875 +title: Step 098 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Change the `random` function so that it returns `Math.floor(Math.random() * y + x)`. +It now returns a random number within a range. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/["']?random["']?:\(\[x,y\]\)=>Math\.floor\(Math\.random\(\)\*y\+x\)/.test(code.replace(/\s/g, "")) && spreadsheetFunctions["random"]([1, 1]) === 1); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-099.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-099.md new file mode 100644 index 0000000000..28e29ebd25 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-099.md @@ -0,0 +1,302 @@ +--- +id: 5d7925381e8565a5c50ba7f1 +title: Step 099 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +In functional programming, we strive to use a type of function called "pure functions" as much as possible. +The first property of pure functions is that they always return the same value for the same arguments. +You can check if this is the case by comparing a call to a function with another call (with the same arguments): + +```js +console.log(f(2) === f(2)); // always true for pure functions +``` + +Use this technique to check if the `random` function in `spreadsheetFunctions` is pure by passing in the following array: `[1, 1000]`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/(spreadsheetFunctions\[["']random["']\]\(1,1000\))===\1/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-100.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-100.md new file mode 100644 index 0000000000..b51baa6dfa --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-100.md @@ -0,0 +1,298 @@ +--- +id: 5d7925383f1b77db7f1ff59e +title: Step 100 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +This is (probably) false, so `random` is certainly impure. +The second property of pure functions is that they perform no side effects, which are state and I/O modifications. +If you call a function without assigning the result to a variable, and it does something, then it's an impure function. +Call `window.onload()` in `update`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/update=\(?event\)?=>\{.*window\.onload\(\).*\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-101.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-101.md new file mode 100644 index 0000000000..87cc83a6e2 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-101.md @@ -0,0 +1,294 @@ +--- +id: 5d792538de9fa3f298bcd5f6 +title: Step 101 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Now try calling `highPrecedence` and pass it the string `"2*2"` without assigning it to a variable in `update`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/update=\(?event\)?=>\{.*highPrecedence\((['"])2\*2\1\).*\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-102.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-102.md new file mode 100644 index 0000000000..cd154fcce2 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-102.md @@ -0,0 +1,295 @@ +--- +id: 5d7925385b74f69642e1fea5 +title: Step 102 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Obviously, this was ignored, as all `highPrecedence` does is return a value and this value is ignored. +Now compare `highPrecedence("2*2")` with `highPrecedence("2*2")`, and `console.log` the result. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/update=\(?event\)?=>\{.*console\.log\((highPrecedence\(['"]2\*2['"]\))===\1\).*\}/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-103.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-103.md new file mode 100644 index 0000000000..83142f3698 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-103.md @@ -0,0 +1,295 @@ +--- +id: 5d7925380ea76d55b2c97d7b +title: Step 103 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +This is true, so `highPrecedence` might be a pure function. +If you inspect it, you can see that it indeed performs no I/O and doesn't use functions like `Math.random()` - so it's pure. +Remove the `console.log` statement. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(!code.includes("console.log")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-104.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-104.md new file mode 100644 index 0000000000..0fade63b07 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-104.md @@ -0,0 +1,295 @@ +--- +id: 5d792538be4fe331f1a6c008 +title: Step 104 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Unfortunately, impure functions are necessary - if you don't use them, the application won't perform any I/O so won't do anything. +But we have an impure function that could be pure - `evalFormula`. +It calls `document.getElementById(c + n).value`, but this value can change, even if the arguments don't. +Change these calls to `""` - the function is now pure but doesn't work. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: const nos = code.replace(/\s/g, ""); assert(nos.includes('elemValue=n=>c=>""') && nos.includes('match=>""')) + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-105.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-105.md new file mode 100644 index 0000000000..e476847aef --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-105.md @@ -0,0 +1,293 @@ +--- +id: 5d792538d169f33142175b95 +title: Step 105 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +To make this function pure, instead of depending on application state implicitly, we can pass it down explicitly as an argument. +Add an argument `cells` to `evalFormula`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("evalFormula=(x,cells)=>{")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-106.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-106.md new file mode 100644 index 0000000000..86aec97f86 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-106.md @@ -0,0 +1,296 @@ +--- +id: 5d792538e48b5a2c6e5bbe12 +title: Step 106 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +When calling `evalFormula` in `update`, pass in `Array.from(document.getElementById("container").children)` as the `cells` argument. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes('evalFormula(value.slice(1),Array.from(document.getElementById("container").children))')); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-107.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-107.md new file mode 100644 index 0000000000..3cbd2d5cac --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-107.md @@ -0,0 +1,298 @@ +--- +id: 5d7925387f3e9da5ec856dbe +title: Step 107 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Update the recursive call to `evalFormula` by passing in `cells` as the second argument. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("evalFormula(functionExpanded,cells)")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-108.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-108.md new file mode 100644 index 0000000000..e342b18ddd --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-108.md @@ -0,0 +1,299 @@ +--- +id: 5d79253824ae9b4a6e6f3108 +title: Step 108 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add a function `idToText` to `evalFormula`, which takes the argument `id` and returns `cells`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/constidToText=\(?id\)?=>cells/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-109.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-109.md new file mode 100644 index 0000000000..81fa24eca7 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-109.md @@ -0,0 +1,300 @@ +--- +id: 5d7925383f122a279f4c54ad +title: Step 109 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `find` method returns the first element of an array that satisfies the function passed to it. +Chain `find` onto `cells` and pass it `cell => cell === id`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/constidToText=\(?id\)?=>cells\.find\(\(?cell\)?=>cell===id\)/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-110.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-110.md new file mode 100644 index 0000000000..7db5eb2e46 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-110.md @@ -0,0 +1,298 @@ +--- +id: 5d7925387b682e962f209269 +title: Step 110 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +In `idToText`, use the `id` property of `cell` to make sure the argument is equal to the cell's id rather than the cell itself. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/constidToText=\(?id\)?=>cells\.find\(\(?cell\)?=>cell\.id===id\)/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-111.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-111.md new file mode 100644 index 0000000000..f423b425be --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-111.md @@ -0,0 +1,298 @@ +--- +id: 5d792538de774217b173288e +title: Step 111 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Use the `value` property on the result of `idToText` to return the text inside the cell, rather than the cell itself. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/constidToText=\(?id\)?=>cells\.find\(\(?cell\)?=>cell\.id===id\)\.value/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-112.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-112.md new file mode 100644 index 0000000000..a8886e2465 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-112.md @@ -0,0 +1,299 @@ +--- +id: 5d79253891d93585323d1f3c +title: Step 112 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Change the empty string in `elemValue` to the result of calling `idToText` with `c + n`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("elemValue=n=>c=>idToText(c+n)")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-113.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-113.md new file mode 100644 index 0000000000..7247af97af --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-113.md @@ -0,0 +1,300 @@ +--- +id: 5d7925384e34e944ecb4612d +title: Step 113 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Change the empty string in `varExpanded` to the result of calling `idToText` with `match.toUpperCase()`. + +
+ +## Instructions +
+ + + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("match=>idToText(match.toUpperCase())")) + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-114.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-114.md new file mode 100644 index 0000000000..cd69c94ed0 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-114.md @@ -0,0 +1,302 @@ +--- +id: 5d792538631844ad0bdfb4c3 +title: Step 114 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +`evalFormula` is now pure, as it now has no external dependencies, and as before, performs no side effects. +Now define a new function, `increment` inside `spreadsheetFunctions`, which takes `nums` as argument and uses `map` to increment each value of `nums` by 1. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(JSON.stringify(spreadsheetFunctions.increment([1, 5, 3])) === "[2,6,4]"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-115.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-115.md new file mode 100644 index 0000000000..d330c01f2d --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-115.md @@ -0,0 +1,306 @@ +--- +id: 5d792538e2a8d20cc580d481 +title: Step 115 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `slice` method can also work on arrays. +Add a method `firsttwo` to `spreadsheetFunctions` which takes `arr` as argument and uses `slice` to return the first two elements of `arr`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(JSON.stringify(spreadsheetFunctions.firsttwo([2, 6, 1, 4, 3])) === "[2,6]"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-116.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-116.md new file mode 100644 index 0000000000..4b51a769ab --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-116.md @@ -0,0 +1,313 @@ +--- +id: 5d792538f5004390d6678554 +title: Step 116 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +You can also pass in a negative argument to `slice` to specify that index from the end: + +```js +[2, 4, 6, 8, 10].slice(-3); // [6, 8, 10] +``` + +Use a negative index to add a function `lasttwo` which returns the last two elements of an array. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(JSON.stringify(spreadsheetFunctions.lasttwo([2, 6, 1, 4, 3])) === "[4,3]"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-117.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-117.md new file mode 100644 index 0000000000..6477ae02c6 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-117.md @@ -0,0 +1,318 @@ +--- +id: 5d792539dd4fd4c96fd85f7e +title: Step 117 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `%` operator returns the remainder: + +```js +4 % 3; // 1 +5 % 3; // 2 +6 % 3; // 0 +``` + +Add an `isEven` function (to the global scope) which returns whether the number passed to it is even. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(isEven(20) && !isEven(31)); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-118.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-118.md new file mode 100644 index 0000000000..c88cf66421 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-118.md @@ -0,0 +1,319 @@ +--- +id: 5d79253949802f8587c8bbd3 +title: Step 118 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `filter` method keeps only the elements of an array that satisfy the function passed to it: + +```js +[1, 10, 8, 3, 4, 5].filter(x > 3); // [10, 8, 4, 5] +``` + +Use `filter` to add a function called `even` to `spreadsheetFunctions`, which returns all the even elements of an array, `nums`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(JSON.stringify(spreadsheetFunctions.even([2,3,5,6,9,4])) === "[2,6,4]" && code.includes("filter")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-119.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-119.md new file mode 100644 index 0000000000..174df4e76e --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-119.md @@ -0,0 +1,324 @@ +--- +id: 5d7925395888767e9304c082 +title: Step 119 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `reduce` method takes a function which an accumulator and the current value. +The accumulator is initially set to the value at index 0. +The `reduce` method then goes through each element of the array after that, passing in the element as the current value and the result of the last call as the accumulator. +For example, here'how to multiply all the value in an array: + +```js +[2, 3, 4].reduce((a, x) => a * x); // 24 +``` + +Using `reduce`, add a function `sum` to `spreadsheetFunctions`, which sums all values in the array passed to it. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(spreadsheetFunctions.sum([10,5,1,3]) === 19 && code.includes("reduce")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-120.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-120.md new file mode 100644 index 0000000000..97d0b9fabb --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-120.md @@ -0,0 +1,318 @@ +--- +id: 5d7925393b30099e37a34668 +title: Step 120 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `includes` method checks if an element is in an array. +Add a `has2` function to `spreadsheetFunctions` which checks if the inputted array has the number 2 in it. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(spreadsheetFunctions.has2([2,3,5]) && !spreadsheetFunctions.has2([1,3,10])); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-121.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-121.md new file mode 100644 index 0000000000..73b2e313a6 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-121.md @@ -0,0 +1,328 @@ +--- +id: 5d7925398157757b23730fdd +title: Step 121 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `reduce` method can take a second argument (in addition to the function), specifying the initial accumulator value. +In this case, the current value starts from index 0 rather than index 1. + +```js +[1, [1, 2, 3], [3, 4, 5]].reduce((a, x) => a.concat(x), []); // [1, 1, 2, 3, 3, 4, 5] +// without the second argument, it first tries 1.concat([1, 2, 3]), but 1 is not an array +// now it first tries [].concat(1) which works +``` + +Add a function `nodups` to `spreadsheetFunctions`, with the value `arr => arr.reduce((a, x) => a.includes(x), [])`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/nodups['"]?:arr=>arr\.reduce\(\(a,x\)=>a\.includes\(x\),\[\]\)/.test(code.replace(/\s/g, ""))) + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-122.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-122.md new file mode 100644 index 0000000000..6924f936eb --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-122.md @@ -0,0 +1,320 @@ +--- +id: 5d792539de4b9ac14dd40409 +title: Step 122 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Use the ternary operator in `nodups` to return `a` if `a.includes(x)` and `a.concat(x)` otherwise. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(JSON.stringify(spreadsheetFunctions.nodups([1,3,1,5,7,7,9,7])) === "[1,3,5,7,9]"); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-123.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-123.md new file mode 100644 index 0000000000..acc61bd989 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-123.md @@ -0,0 +1,329 @@ +--- +id: 5d792539534f1bf991bb987f +title: Step 123 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +ES6 introduced a shorthand object literal syntax: + +```js +const a = 10; +const myObject = { a }; +console.log(myObject); // { a: 10 } +``` + +First, move `sum` outside of `spreadsheetFunctions`. +`sum` should be a function expression similar to `isEven`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(sum([1,2,3]) === 6); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-124.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-124.md new file mode 100644 index 0000000000..869cc5bb1c --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-124.md @@ -0,0 +1,322 @@ +--- +id: 5d7925394089b762f93ffa52 +title: Step 124 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Now use the shorthand syntax to reference `sum` inside of `spreadsheetFunctions`. +This both adds it to the functions you can use in the spreadsheet, and allows you to use it throughout your program. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/[{,]sum[,}]/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-125.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-125.md new file mode 100644 index 0000000000..5093ac9efc --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-125.md @@ -0,0 +1,326 @@ +--- +id: 5d792539ec758d45a6900173 +title: Step 125 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `length` property returns the length of an array. +Use this property with the `sum` function to define an `average` function. +As with `sum`, add this function to both the global scope and to `spreadsheetFunctions`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(average([1, 5, 12]) === 6 && spreadsheetFunctions.average([1, 20, 3, 8]) === 8); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-126.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-126.md new file mode 100644 index 0000000000..d7d96d72ed --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-126.md @@ -0,0 +1,335 @@ +--- +id: 5d7925398d525f61a9ff3a79 +title: Step 126 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The spread operator allow you to pass multiple arguments instead of an array: + +```js +const arr = [1, 2, 3]; +const sum3 = (a, b, c) => a + b + c; +sum3(...arr); // 6 +``` + +Use the spread operator to add `range` to `spreadsheetFunctions`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(JSON.stringify(spreadsheetFunctions.range([1, 5])) === "[1,2,3,4,5]" && code.includes("...")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-127.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-127.md new file mode 100644 index 0000000000..9b77dfca40 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-127.md @@ -0,0 +1,330 @@ +--- +id: 5d792539a222f385c5c17d2b +title: Step 127 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Now define a `median` function which takes an argument `nums` (in the global scope). + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/constmedian=\(?nums\)?=>/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-128.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-128.md new file mode 100644 index 0000000000..a8a1f0bd70 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-128.md @@ -0,0 +1,340 @@ +--- +id: 5d7925398a7184b41b12a0e0 +title: Step 128 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `sort` method sorts an array alphabetically: + +```js +["B", "C", "A"].sort(); // ["A", "B", "C"] +``` + +Assign the sorted `nums` to `sorted` in `median`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constmedian=nums=>{constsorted=nums.sort()")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-129.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-129.md new file mode 100644 index 0000000000..3f4689f709 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-129.md @@ -0,0 +1,345 @@ +--- +id: 5d7925399afb905c34730a75 +title: Step 129 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +But our function takes an array of numbers, not strings. +Luckily, you can pass a function `fn` as argument to sort: + +```js +[2, 9, 10, 15].sort((a, b) => b - a); // [10, 9, 5, 2] +``` + +If `b - a` is less than 0, then `a` will be placed before `b`. +As a result, this sorts the array in descending order. +Use `sort` to sort `nums` in ascending order. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/constmedian=nums=>\{constsorted=nums\.sort\(\((.+),(.+)\)=>\1-\2\)/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-130.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-130.md new file mode 100644 index 0000000000..bb9379e6b7 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-130.md @@ -0,0 +1,338 @@ +--- +id: 5d792539728d1aa7788e2c9b +title: Step 130 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Unfortunately, `sort` not only returns a new array, but also modifies the existing one. +So our function also modifies the array passed to it - it is impure. +You can fix this by adding `.slice()` between `nums` and `sort` - this creates a new array, that is equivalent to `nums`, but is immediately discarded, so it doesn't matter if it changes. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/constmedian=nums=>\{constsorted=nums\.slice\(\)\.sort\(\((.+),(.+)\)=>\1-\2\)/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-131.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-131.md new file mode 100644 index 0000000000..e3fd6ae257 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-131.md @@ -0,0 +1,338 @@ +--- +id: 5d79253939434a2724c0ec41 +title: Step 131 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Now define two variable: `length` which is `sorted.length` and `middle` which is `length / 2 - 1`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/constmedian=nums=>\{constsorted=nums\.slice\(\)\.sort\(\((.+),(.+)\)=>\1-\2\);?constlength=sorted\.length;?constmiddle=length\/2-1/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-132.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-132.md new file mode 100644 index 0000000000..ec4d0e0075 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-132.md @@ -0,0 +1,341 @@ +--- +id: 5d792539b9e1d3c54d8fe94a +title: Step 132 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add a return statement to `median` so that it returns `isEven(length)`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(median([1,2,3,4]) && !median([1,2,3])); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-133.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-133.md new file mode 100644 index 0000000000..838946daee --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-133.md @@ -0,0 +1,345 @@ +--- +id: 5d792539b2e0bd8f9e8213e4 +title: Step 133 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Use the ternary operator to return `average([sorted[middle], sorted[middle + 1]])` if `length` is even, and `sorted[middle + 0.5]` otherwise. +Note that the `middle` variable is close to the middle but is not actually the middle. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(median([1, 20, 3]) === 3 && median([27, 7, 20, 10]) === 15); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-134.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-134.md new file mode 100644 index 0000000000..2be1b016f5 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-134.md @@ -0,0 +1,347 @@ +--- +id: 5d792539239148965a1a59a5 +title: Step 134 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Now add `median` to `spreadsheetFunctions`, just like you added `sum` and `average`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(spreadsheetFunctions.median([1, 20, 3]) === 3 && spreadsheetFunctions.median([27, 7, 20, 10]) === 15); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-135.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-135.md new file mode 100644 index 0000000000..4d274ba793 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-135.md @@ -0,0 +1,350 @@ +--- +id: 5d792539e1446045d0df6d28 +title: Step 135 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `some` method checks if any element of the array satisfies the provided testing function. +Add `someeven` to `spreadsheetFunctions`, which checks if any of the items passed in are even. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(spreadsheetFunctions.someeven([1, 5, 4, 3]) && !spreadsheetFunctions.someeven([3, 5, 9]) && code.includes(".some")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-136.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-136.md new file mode 100644 index 0000000000..5e6cd288c5 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-136.md @@ -0,0 +1,352 @@ +--- +id: 5d79253a2febbb77098730b9 +title: Step 136 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `every` method checks if all elements of an array satisfy the provided testing function. +Use it to add an `everyeven` function to `spreadsheetFunctions` which checks if all values passed in are even`spreadsheetFunctions` which checks if all values passed in are even. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(spreadsheetFunctions.everyeven([2, 6, 4, 0, 20]) && !spreadsheetFunctions.everyeven([10, 0, 9, 2]) && code.includes(".every")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-137.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-137.md new file mode 100644 index 0000000000..22a05077ac --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-137.md @@ -0,0 +1,355 @@ +--- +id: 5d79253a98bd9fdf7ce68d0a +title: Step 137 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +We've used recursion in `range`, but recursion can have performance issues in JavaScript. +If performance is an issue, you should try to use a higher order function like `reduce`, and if you can't do that, you'll probably have to use a for/while loop. +While we don't expect the user to enter particularly large numbers so that performance is an issue, we're going to refactor `range` as an exercise. +Replace the body of `range` with `start`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(/constrange=\(start,end\)=>start(;|const)/.test(code.replace(/\s/g, ""))); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-138.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-138.md new file mode 100644 index 0000000000..16702d0f4c --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-138.md @@ -0,0 +1,351 @@ +--- +id: 5d79253a1e9abf29de64c177 +title: Step 138 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `Array` function takes an argument `x` and creates an array of size `x` filled with `undefined`. +Make `range` return an array of `undefined` with size `end - start + 1`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constrange=(start,end)=>Array(end-start+1)")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-139.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-139.md new file mode 100644 index 0000000000..cb2c658031 --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-139.md @@ -0,0 +1,352 @@ +--- +id: 5d79253a8b29d78984369e4b +title: Step 139 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `fill` method takes an argument and replaces all elements of the array with that argument. +Use it on the array in `range` to replace everything with `start`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constrange=(start,end)=>Array(end-start+1).fill(start)")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-140.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-140.md new file mode 100644 index 0000000000..7c85784dbb --- /dev/null +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-spreadsheet/step-140.md @@ -0,0 +1,353 @@ +--- +id: 5d79253ad297a31cbe073718 +title: Step 140 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The function in the `map` method can actually take a second argument: the index of the element. +This is why you need an arrow function in `charRange` - if you don't use one, then the index will be passed to `String.fromCharCode` as the second argument, leading to unexpected results. +However, it is safe for functions like `parseFloat` which take only one argument (but not for `parseInt`). +Chain `.map((x, i) => x + i)` to `.fill(start)` to add its index to every element in the array in `range`. + +
+ +## Instructions +
+ + +
+ +## Tests +
+ +```yml +tests: + - text: See description above for instructions. + testString: assert(code.replace(/\s/g, "").includes("constrange=(start,end)=>Array(end-start+1).fill(start).map((x,i)=>x+i)")); + +``` + + +
+ +## Challenge Seed +
+ +
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + + Spreadsheet + + + +
+
+
+``` + +
+ + +### After Test +
+ +```html + + +``` + +
+ + + +
+ +## Solution +
+ +```html + +``` + +
diff --git a/utils/block-nameify.js b/utils/block-nameify.js index 8122963374..983c88360f 100644 --- a/utils/block-nameify.js +++ b/utils/block-nameify.js @@ -18,7 +18,8 @@ const preFormattedBlockNames = { 'machine-learning-with-python': 'Machine Learning with Python', tensorflow: 'TensorFlow', 'javascript-rpg-game': 'JavaScript RPG Game', - 'css-variables-skyline': 'CSS Variables Skyline' + 'css-variables-skyline': 'CSS Variables Skyline', + 'javascript-spreadsheet': 'JavaScript Spreadsheet' }; const noFormatting = ['and', 'for', 'of', 'the', 'up', 'with'];