Skip to content

Commit a6b1e98

Browse files
committed
I did Sprint 1 for module 2
1 parent 3372770 commit a6b1e98

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ 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
6-
// Describe what line 3 is doing, in particular focus on what = is doing
7+
// line 3 is increase the value of count by 1 and save the value into count variable.

Sprint-1/1-key-exercises/2-initials.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ let lastName = "Johnson";
55
// Declare a variable called initials that stores the first character of each string.
66
// This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution.
77

8-
let initials = ``;
8+
// this variable storage the first character of each string
9+
let initials = firstName.charAt(0) + middleName.charAt(0) + lastName.charAt(0);
910

1011
// https://www.google.com/search?q=get+first+character+of+string+mdn
1112

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ console.log(`The base part of ${filePath} is ${base}`);
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

20-
const dir = ;
21-
const ext = ;
20+
// dir: everything before the last slash
21+
const dir = filePath.slice(0, lastSlashIndex);
22+
23+
// ext: everything after the last dot in the base
24+
const lastDotIndex = base.lastIndexOf(".");
25+
const ext = base.slice(lastDotIndex + 1);
26+
27+
console.log(`Dir: ${dir}`);
28+
console.log(`Ext: ${ext}`);
2229

2330
// https://www.google.com/search?q=slice+mdn

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@ 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 means
89
// It will help to think about the order in which expressions are evaluated
910
// Try logging the value of num and running the program several times to build an idea of what the program is doing
11+
12+
13+
// Math.random() generates random number . up to 0 but not include 1
14+
// this (maximum - minimum + 1) gives the range of generated random number
15+
// and this function Math.floor() make the number to the nearest integer number.
16+
// num is a random integer between minimum (1) and maximum (100), including 1 & 100
17+
18+
console.log(num);

0 commit comments

Comments
 (0)