--- id: 587d7b8c367417b2b2512b56 title: Use export to Reuse a Code Block 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 several different javascript files. In order to share the function with the files, you need to first export it. ```js export const capitalizeFirstLetter = (string) => { return string.charAt(0).toUpperCase() + string.slice(1); } ``` The above is a common way to export a single function, but you can achieve the same thing like this: ```js const capitalizeFirstLetter = (string) => { return string.charAt(0).toUpperCase() + string.slice(1); } 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
Create and export a variable named
## Tests
```yml tests: - text: foo is exported. testString: getUserInput => assert(getUserInput('index').match(/export\s+const\s+foo\s*=\s*"bar"/g), 'foo is exported.'); - text: bar is exported. testString: getUserInput => assert(getUserInput('index').match(/export\s+const\s+bar\s*=\s*"foo"/g), 'bar is exported.'); ```
## Challenge Seed
```js "use strict"; ```
### Before Test
```js self.exports = function(){}; ```
## Solution
```js "use strict"; export const foo = "bar"; export const bar = "foo"; ```