--- id: 587d7b8c367417b2b2512b56 title: Use export to Share a Code Block challengeType: 1 --- ## Description
Imagine a file called math_functions.js, it contains several functions related to mathematical operations. One of them is stored in a variable, add, that takes in two numbers and returns the sum of them. You want to use this function in several different javascript files. In order to share it with the files, you need to first export it. ```js export const add = (x, y) => { return x + y; } ``` The above is a common way to export a single variable, but you can achieve the same thing like this: ```js const add = (x, y) => { return x + y; } export { add }; ``` After you export a variable, you can import it in another file to use without having to rewrite the code. You can export multiple variables one at a time by repeating the first example for each thing you want to export or by placing them all in the export statement of the second example like this: ```js export { add, subtract }; ```
## Instructions
There are two functions related to strings in the editor. Export both of them using the method of your choice.
## Tests
```yml tests: - text: You should not alter the functions. testString: getUserInput => assert(getUserInput('index').match(/export\s+const\s+foo\s*=\s*"bar"/g), 'foo is exported.'); - text: capitalizeString is properly exported. testString: getUserInput => assert(getUserInput('index').match(/export\s+const\s+bar\s*=\s*"foo"/g), 'bar is exported.'); - text: lowerCaseString is properly exported. ```
## Challenge Seed
```js const capitalizeString = (string) => { return string.toUpperCase(); } const lowercaseString = (string) => { return string.toLowerCase() } ```
### Before Test
```js self.exports = function(){}; ```
## Solution
```js export const capitalizeString = (string) => { return string.toUpperCase(); } export const lowercaseString = (string) => { return string.toLowerCase() } ```