Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Susanne Raml
fullstack-node
Commits
13369712
Commit
13369712
authored
Apr 17, 2021
by
Susanne Raml
Browse files
Add all modules exercises
parent
04f78f1a
Changes
14
Hide whitespace changes
Inline
Side-by-side
node/exercises/modules-cjs/assets/drums/index.js
0 → 100644
View file @
13369712
const
drumset
=
require
(
"
./assets/drumset
"
);
node/exercises/modules-cjs/assets/drumset/bass/index.js
0 → 100644
View file @
13369712
const
bass
=
{
name
:
'
Bass
'
,
play
:
()
=>
{
return
'
buff
'
}
}
module
.
exports
=
bass
;
\ No newline at end of file
node/exercises/modules-cjs/assets/drumset/index.js
0 → 100644
View file @
13369712
exports
.
snare
=
require
(
'
./snare
'
);
exports
.
bass
=
require
(
'
./bass
'
);
\ No newline at end of file
node/exercises/modules-cjs/assets/drumset/snare/index.js
0 → 100644
View file @
13369712
const
snare
=
{
name
:
'
Snare
'
,
play
:
()
=>
{
return
'
klack
'
}
}
module
.
exports
=
snare
;
node/exercises/modules-cjs/assets/hello.js
0 → 100644
View file @
13369712
module
.
exports
=
function
hello
()
{
return
'
hello world
'
;
};
node/exercises/modules-cjs/assets/string.js
0 → 100644
View file @
13369712
function
firstChar
(
str
)
{
return
str
.
charAt
(
0
);
}
function
lastChar
(
str
)
{
return
str
.
charAt
(
str
.
length
-
1
);
}
function
length
(
str
)
{
return
str
.
length
;
}
module
.
exports
=
{
firstChar
,
lastChar
,
length
};
\ No newline at end of file
node/exercises/modules-esm/export/counter.mjs
View file @
13369712
...
...
@@ -4,3 +4,9 @@
* - Define a named export 'counter' and initialize it with 0.
* - Define a named function export countUp() which counts up the counter.
*/
let
counter
=
0
;
function
countUp
()
{
return
counter
++
;
}
export
{
counter
,
countUp
};
\ No newline at end of file
node/exercises/modules-esm/export/drumset.mjs
View file @
13369712
...
...
@@ -5,7 +5,7 @@
* - Export an instance (singleton) of the class as default export
*/
class
Drumset
{
export
class
Drumset
{
snare
()
{
return
"
klack
"
;
}
...
...
@@ -13,3 +13,5 @@ class Drumset {
return
"
badumm
"
;
}
}
export
default
new
Drumset
();
\ No newline at end of file
node/exercises/modules-esm/export/helloWorld.mjs
View file @
13369712
/**
* ⚠️☝️ INSTRUCTIONS ☝️⚠️
*
* - Export a helloWorld function as default export
*/
\ No newline at end of file
*/
function
helloWorld
()
{
return
'
helloWorld
'
;
};
export
default
helloWorld
;
\ No newline at end of file
node/exercises/modules-esm/main.mjs
View file @
13369712
...
...
@@ -17,8 +17,14 @@
// import * as something from "...";
// ⛳️ Implement a function that calls countUp() and returns the current counter.
export
function
countUpAndReturnCounter
()
{
import
helloWorld
from
"
./export/helloWorld
"
;
import
{
countUp
,
counter
as
currentCounter
}
from
"
./export/counter
"
import
drumsetSingleton
,
*
as
drumset
from
'
./export/drumset
'
export
function
countUpAndReturnCounter
()
{
countUp
();
return
currentCounter
;
}
// ⚠️ NOTE ⚠️:
...
...
node/exercises/modules-interop/exercise1.mjs
View file @
13369712
// 📝 Import "./cjs-modules/module1.cjs" and make the console logs work.
// Write your code below this comment!
import
myModule
from
"
./cjs-modules/module1.cjs
"
// ⛔ Do not edit the console logs
console
.
log
(
myModule
.
a
);
...
...
node/exercises/modules-interop/exercise2.mjs
View file @
13369712
// 📝 Import "./cjs-modules/module2.cjs" and make the console logs work.
// Write your code below this comment!
import
{
a
,
b
}
from
"
./cjs-modules/module2.cjs
"
// ⛔ Do not edit the console logs
console
.
log
(
a
);
...
...
node/exercises/modules-interop/exercise3.mjs
View file @
13369712
// 📝 Import "./cjs-modules/module1.cjs" and make the console logs work.
// Write your code below this comment!
import
all
from
"
./cjs-modules/module1.cjs
"
;
const
{
a
,
b
}
=
all
;
// ⛔ Do not edit the console logs
console
.
log
(
a
);
...
...
node/exercises/modules-interop/exercise4.mjs
View file @
13369712
// 📝 Import "./cjs-modules/module1.cjs" and make the console logs work.
// Write your code below this comment!
import
*
as
myModule
from
"
./cjs-modules/module1.cjs
"
;
//const {a, b} = myModule;
// ⛔ Do not edit the console logs
console
.
log
(
myModule
.
default
.
a
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment