Commit 13369712 authored by Susanne Raml's avatar Susanne Raml
Browse files

Add all modules exercises

parent 04f78f1a
const drumset = require("./assets/drumset");
const bass = {
name: 'Bass',
play: () => {
return 'buff'
}
}
module.exports = bass;
\ No newline at end of file
exports.snare = require('./snare');
exports.bass = require('./bass');
\ No newline at end of file
const snare = {
name: 'Snare',
play: () => {
return 'klack'
}
}
module.exports = snare;
module.exports = function hello() {
return 'hello world';
};
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
......@@ -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
......@@ -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
/**
* ⚠️☝️ 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
......@@ -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 ⚠️:
......
// 📝 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);
......
// 📝 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);
......
// 📝 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);
......
// 📝 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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment