Skip to content

Commit ae2a475

Browse files
solving some practice before moving to course work
1 parent 3372770 commit ae2a475

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
let count = 0;
22

33
count = count + 1;
4+
/* in line three, the variable count is combining the variable count original value of 0 with new value of 1 with the used of plus operator.
5+
The equal operator is this case helping to re-assign the new value back to the count variable
6+
*/
7+
console.log(count);
48

59
// Line 1 is a variable declaration, creating the count variable with an initial value of 0
610
// Describe what line 3 is doing, in particular focus on what = is doing

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+
let initials = firstName.slice(0,1)+middleName.slice(0,1)+lastName.slice(0,1);
9+
console.log(initials);
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: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ 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
19-
20-
const dir = ;
21-
const ext = ;
22-
19+
const slashIndex = filePath.indexOf("/");
20+
const dir =filePath.slice(slashIndex + 0, 45) ;
21+
const ext =filePath.slice(slashIndex + 49, 53);
22+
console.log(`The dir part of ${filePath} is ${dir}`);
23+
console.log(`The ext part of ${filePath} is ${ext}`);
2324
// 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+
console.log(num)
7+
68
// In this exercise, you will need to work out what num represents?
79
// Try breaking down the expression and using documentation to explain what it means
810
// It will help to think about the order in which expressions are evaluated
911
// Try logging the value of num and running the program several times to build an idea of what the program is doing
12+
13+
/*Number data type represents any type of number such as integer, float number(decimal number), infinity number, etc...
14+
In the code at line 4 the num variable are doing math function that generate a integer between variable minimum and maximum value,
15+
the floor method behind the Math are is main purpose if to help turn value of a float number and round it up to the nearest integer.
16+
inside the Math.floor parameter the math random method is choosing a random float number between 0 and 1 and have it multiply with the second expression
17+
to set the range of possible value range from 0 to under 100. The last plus one to make sure the that number stay above 0(0+1) and to 100(99+1);
18+
*/

0 commit comments

Comments
 (0)