Skip to content

Commit bb9f61e

Browse files
committed
chapter examples
1 parent adbedb1 commit bb9f61e

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

modules/exporting-modules/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
11
// Import the modules exported from practiceExports.js below:
2+
3+
const practice = require('./practiceExports'); //pull the function in and assign it to a variable
4+
5+
console.log(typeof practice); //returns function.
6+
console.log(practice.isPalindrome('that'));
7+
console.log(practice.isPalindrome('radar'));
8+
9+
let arr = ['Hello', 'World', 123, 987, 'LC101'];
10+
11+
console.log(practice.isPalindrome('mom'));
12+
console.log(practice.evenOrOdd(9));
13+
14+
for (i=0; i < 3; i++){
15+
console.log(practice.randomArrayElement(arr));
16+
}

modules/exporting-modules/practiceExports.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
function isPalindrome(str){
2+
23
return str === str.split('').reverse().join('');
34
}
45

@@ -14,3 +15,12 @@ function randomArrayElement(arr){
1415
let index = Math.floor(Math.random()*arr.length);
1516
return arr[index];
1617
}
18+
19+
20+
// module.exports = isPalindrome;
21+
22+
module.exports = {
23+
isPalindrome: isPalindrome,
24+
evenOrOdd: evenOrOdd,
25+
randomArrayElement: randomArrayElement
26+
}

0 commit comments

Comments
 (0)