Tom 17a55c6e18
fix(curriculum): Consolidated comments for JavaScript Algorithms and Data Structures challenges - part 1 of 4 (#38258)
* fix: consolidate/remove comments

* fix: remove => from comment

* fix: reverted changes to add same changes to another PR

* fix: removed 'the' from sentence

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* fix: removed 'the' from the sentence

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
2020-03-04 13:08:54 -06:00

2.1 KiB
Raw Blame History

id, title, challengeType, forumTopicId
id title challengeType forumTopicId
5cddbfd622f1a59093ec611d Create a Module Script 6 301198

Description

JavaScript started with a small role to play on an otherwise mostly HTML web. Today, its huge, and some websites are built almost entirely with JavaScript. In order to make JavaScript more modular, clean, and maintainable; ES6 introduced a way to easily share code among JavaScript files. This involves exporting parts of a file for use in one or more other files, and importing the parts you need, where you need them. In order to take advantage of this functionality, you need to create a script in your HTML document with a type of module. Heres an example:
<script type="module" src="filename.js"></script>

A script that uses this module type can now use the import and export features you will learn about in the upcoming challenges.

Instructions

Add a script to the HTML document of type module and give it the source file of index.js

Tests

tests:
  - text: You should create a <code>script</code> tag.
    testString: assert(code.match(/<\s*script[^>]*>\s*<\/\s*script\s*>/g));
  - text: Your <code>script</code> tag should be of type <code>module</code>.
    testString: assert(code.match(/<\s*script\s+[^t]*type\s*=\s*('|")module\1[^>]*>\s*<\/\s*script\s*>/g));
  - text: Your <code>script</code> tag should have a <code>src</code> of <code>index.js</code>.
    testString: assert(code.match(/<\s*script\s+[^s]*src\s*=\s*('|")index\.js\1[^>]*>\s*<\/\s*script\s*>/g));

Challenge Seed

<html>
  <body>
    <!-- Only change code below this line -->

    <!-- Only change code above this line -->
  </body>
</html>

Solution

<html>
  <body>
    <script type="module" src="index.js"></script>
  </body>
</html>