diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-a-module-script.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-a-module-script.english.md index 0bef05a8a8..f1e329b37b 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-a-module-script.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-a-module-script.english.md @@ -1,12 +1,12 @@ --- id: 5cddbfd622f1a59093ec611d title: Create a Module Script -challengeType: 1 +challengeType: 6 --- ## Description
-Javascript started with a small role to play on an otherwise mostly html internet. Today, it’s huge, and some websites are built almost entirely with javascript. In order to make javascript more modular, clean, and maintainable, ES6 introduced a way easily share code amongst javascript files. This involves exporting parts of a javascript file for use in one or more other files, and importing the parts you need to each file. In order to take advantage of this functionality, you need to create a script in your html file with a type of module. Here’s an example: +Javascript started with a small role to play on an otherwise mostly html internet. Today, it’s 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 javascript 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. Here’s an example: ```html @@ -26,36 +26,49 @@ Add a script to the html document of type module and give it the so ```yml tests: - - text: var should not exist in code. - testString: getUserInput => assert(!getUserInput('index').match(/var/g),'var should not exist in code.'); - + - text: You should create a script tag. + testString: assert(code.match(/<\s*script[^>]*>\s*<\/\s*script\s*>/g)); + - text: Your script tag should be of type module. + testString: assert(code.match(/<\s*script\s*[^t]*type\s*=\s*('|")module\1[^>]*>\s*<\/\s*script\s*>/g)); + - text: Your script tag should have a src of index.js. + testString: assert(code.match(/<\s*script\s*[^s]*src\s*=\s*('|")index\.js\1[^>]*>\s*<\/\s*script\s*>/g)); ```
## Challenge Seed
-
+ +
```html - - // add your code below - // add your code above + + + + + + + ```
+
## Solution
```html - - // add your code below - // add your code above + + + + + + + ```
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-export-to-reuse-a-code-block.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-export-to-reuse-a-code-block.english.md index aa2e3ca0f6..20c30dabcb 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-export-to-reuse-a-code-block.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-export-to-reuse-a-code-block.english.md @@ -6,7 +6,7 @@ challengeType: 1 ## Description
-Imagine you have a function, capitalizeFirstLetter, that simply takes in a string, and returns the string with the first letter capitalized. You want to use this function in three different javascript files. In order to share the function with the files, you need to first export it. +Imagine you have a function, capitalizeFirstLetter, that simply takes in a string and returns the string with the first letter capitalized. You want to use this function in several different javascript files. In order to share the function with the files, you need to first export it. ```js export const capitalizeFirstLetter = (string) => { @@ -24,6 +24,7 @@ const capitalizeFirstLetter = (string) => { export { capitalizeFirstLetter }; ``` +After you export a function like this, you can import it in another file to use without having to rewrite the function.
## Instructions @@ -52,8 +53,7 @@ tests: ```js "use strict"; -const foo = "bar"; -const bar = "foo"; + ```