diff --git a/curriculum/challenges/_meta/es6/meta.json b/curriculum/challenges/_meta/es6/meta.json index 6932f15b6a..6e8db8334e 100644 --- a/curriculum/challenges/_meta/es6/meta.json +++ b/curriculum/challenges/_meta/es6/meta.json @@ -99,14 +99,17 @@ [ "587d7b8c367417b2b2512b56", "Use export to Share a Code Block" +<<<<<<< HEAD ], [ "587d7b8c367417b2b2512b55", "Reuse Javascript Code Using import" +======= +>>>>>>> fix/rename-lessons ], [ "587d7b8c367417b2b2512b55", - "Share Javascript Code Using import" + "Reuse Javascript Code Using import" ], [ "587d7b8c367417b2b2512b57", diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/share-javascript-code-using-import.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/share-javascript-code-using-import.english.md deleted file mode 100644 index 2f060f42a9..0000000000 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/share-javascript-code-using-import.english.md +++ /dev/null @@ -1,73 +0,0 @@ ---- -id: 587d7b8c367417b2b2512b55 -title: Share Javascript Code Using import -challengeType: 1 ---- - -## Description -
-In the past, require() was used to add things from external files. While handy, this presents a problem: some files are rather large and you may only need certain parts of those external resources. -ES6 gives you a very handy tool known as import. With it, you can choose which parts of a file or module to load, saving time and memory. -Imagine a file that has 20 functions, but you only need to use one of those functions. require() would force you to bring in all 20 functions. With the import syntax, you can bring in just the one you need, like so: -
import { desired_function } from './other_file';
-Here, import will find desired_function in other_file, import just that function for you to use, and ignore the rest. The ./ tells the import to look for the other_file in the same folder that the file which uses the import statement is in. The whitespace around the function inside the curly braces is best practice for readability. -You can import multiple items like this: -
import { item1, item2 } from './other_file';
-There are a few ways to write an import statement, but the above are a very common use-case. -
- -## Instructions -
-Add the appropriate import statement that will allow the current file to use the capitalizeString function. The file where this function lives is called string_functions, and it is in the same directory as the current file. -
- -## Tests -
- -```yml -tests: - - text: Use a valid import statement - testString: getUserInput => assert(getUserInput('index').match(/import\s*\{\s*capitalizeString\s*\}\s*from\s*("|')(\.\/string_functions|string_functions)\1(|\/\/|;\s|\s)/g)); -``` - -
- -## Challenge Seed -
- -
- -```js -"use strict"; - -capitalizeString("hello!"); -``` - -
- -### Before Test -
- -```js -self.require = function (str) { - if (str === 'string_functions') { - return { - capitalizeString: str => str.toUpperCase() - } - } -}; -``` - -
- -
- -## Solution -
- -```js -import { capitalizeString } from './string_functions'; -capitalizeString("hello!"); -``` - -
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-export-to-share-a-code-block.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-export-to-share-a-code-block.english.md index ba92269a04..87c05d8cd8 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-export-to-share-a-code-block.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-export-to-share-a-code-block.english.md @@ -79,5 +79,4 @@ export const lowercaseString = (string) => { return string.toLowerCase() } ``` -