Skip to content

Commit 7134015

Browse files
committed
adding a function on random.js to check the result
1 parent 1f01abe commit 7134015

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Sprint-1/exercises/paths.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ console.log(base); // file.txt
2828
const lastDotIndex = filePath.lastIndexOf(".");
2929
console.log(lastDotIndex); // index position 49
3030
const extractDir = filePath.slice(0, lastDotIndex);
31-
console.log(`Directory and filename (without extension) ${extractDir}`);
31+
console.log(`Directory and filename (without extension) is: ${extractDir}`);
3232

3333

3434
// Create a variable to store the ext part of the variable"

Sprint-1/exercises/random.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
const minimum = 1;
22
const maximum = 100;
33

4-
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
4+
// const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
5+
// console.log(num);
6+
7+
8+
// Math.floor() takes the integer Number
9+
// Math.random() will take a number between 1-100;
10+
11+
512

613
// In this exercise, you will need to work out what num represents?
714
// Try breaking down the expression and using documentation to explain what it means
815
// It will help to think about the order in which expressions are evaluated
916
// Try logging the value of num and running the program several times to build an idea of what the program is doing
17+
18+
19+
20+
function getRandomArbitrary(min, max) {
21+
return Math.random() * (max - min) + min;
22+
}
23+
24+
console.log(getRandomArbitrary(minimum, maximum));

0 commit comments

Comments
 (0)