Importing and Exporting Tasks

Setup

You can quickly get your code base going using repl.it

Be sure to run your code with yarn start in the shell.

Questions

1.

export default a string: "Banana!" in a file banana.js

Import it and console.log( it in index.js

2.

export a const called apple which contains a string: "Apple!" in a file apple.js

Import it and console.log( it in index.js

3.

export default a function in a file myFunctions.js

The function should take two numbers and return the result of multiplying them together.

Import it and console.log( the output in index.js.

4.

Create a file fruits.js

Add an export default of a string 'Get your fruits here'

Add two exported consts pear and blueberry

Import all three and console.log( the output in index.js.

5.

Create a folder pies

Then in index.js, make this work:

import pieMenu, {applePie, blueberryPie} from './pies'

console.log(pieMenu)
// prints "Apple Pie, Blueberry Pie"
console.log(applePie)
// prints "Apple Pie"
console.log(blueberryPie)
// prints "Blueberry Pie"