Skip to content

Commit ba7388c

Browse files
committed
practicing
1 parent 718a5a4 commit ba7388c

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

Sprint-1/1-key-exercises/1-count.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ let count = 0;
22

33
count = count + 1;
44

5+
56
// Line 1 is a variable declaration, creating the count variable with an initial value of 0
67
// Describe what line 3 is doing, in particular what=
7-
Line one shows the initial value is 0 as a variable Declaration,
8-
Line 3 on the right-hand side count + 1 is evaluated first which means the current value 0 adds 1, giving 1
9-
The left-hand side count= means: Assign the result of right-hand side 1 back into the variable
10-
count. So after this runs the output should be 1.
8+
9+
//Line 3 on the right-hand side count + 1 is evaluated first which means the current value 0 adds 1, giving 1
10+
//= means: Assign the result of right-hand side 1 back into the variable, named count. So after line 3, output should be 1

Sprint-1/1-key-exercises/3-paths.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@
1111

1212
const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt";
1313
const lastSlashIndex = filePath.lastIndexOf("/");
14-
const base = filePath.slice(lastSlashIndex + 1);
14+
const base = filePath.slice(lastSlashIndex + 1)
1515
console.log(`The base part of ${filePath} is ${base}`);
1616

1717
// Create a variable to store the dir part of the filePath variable
1818
// Create a variable to store the ext part of the variable
1919
// Get everthing before base
20-
const dir = filePath.slice(0,lastSlashIndex);
21-
2220
//Get everything after the last dot in the base:
23-
const lastDotIndex = base.lastIndexOf(".");
21+
const dir = filePath.slice(0,lastSlashIndex+1);
2422
const ext = base.slice(-3);
2523

2624
console.log(`The dir part of ${filePath} is ${dir}`);

Sprint-1/1-key-exercises/4-random.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ const maximum = 100;
33

44
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
55

6+
67
// In this exercise, you will need to work out what num represents?
78
// Try breaking down the expression and using documentation to explain what it mean
89
// It will help to think about the order in which expressions are evaluated
910

10-
// Try logging the value of num and running the program several times to build an idea of what the program is doingnum reprents the number is randomly generated whole number betweeb 1 and 100,inclusive
11-
Math.random() returns a random decimal between 0(inclusive) and 1(exclusive). while maximum-minimum +1=100, Math.random()*(maximum-minimum+1)
12-
range is between 0 and 99.99999
13-
Due to that Math.floor(...) rounds down the decimal to the nearest whole number.From this Stage, we have interger between o and 99.
14-
After + minimum, the range is between 1 and 100.
15-
This is classcial expressions for generating a random interger between two values- between 1 and 100, inclusive in this function.
16-
This kind of expression is commonly used for things like: rolling dice,random quiz questions, game mechanics.
11+
// Try logging the value of num and running the program several times to build an idea of what the program is doingnum reprents the number is randomly generated whole number betweeb 1 and 100,inclusive range is between 0 and 99.99999
12+
13+
//Math.random() returns a random decimal between 0(inclusive) and 1(exclusive). while maximum-minimum +1=100, Math.random()*(maximum-minimum+1)
14+
15+
//Due to that Math.floor(...) rounds down the decimal to the nearest whole number.From this Stage, we have interger between o and 99.After + minimum, the range is between 1 and 100.
16+
//This is classcial expressions for generating a random integer between two values- between 1 and 100, inclusive in this function.
17+
//This kind of expression is commonly used for things like: rolling dice,random quiz questions, game mechanics.

Sprint-1/2-mandatory-errors/2.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Currently trying to print the string "I was born in Bolton" but it isn't working...
22
// what's the error ?
3+
4+
//my answer:
35
// we should put variable declaration first then print out as JS languages rules, can not write the other way around
46

57
const cityOfBirth = "Bolton";

0 commit comments

Comments
 (0)