Skip to content

Commit d3add85

Browse files
committed
Changes done on Sprint-1/1-key-exercise 1-4.
1 parent 3372770 commit d3add85

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ count = count + 1;
44

55
// Line 1 is a variable declaration, creating the count variable with an initial value of 0
66
// Describe what line 3 is doing, in particular focus on what = is doing
7+
//This means that increase the count number by 1 (by adding 1 to the initial number) and maintain the count value after adding 1. E.g 0+1 =1, so the new count now will be 1.

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[0] + middleName [0] + lastName [0];
99

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

12+
console.log (initials);

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ 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+
const dir = filePath.slice(0, lastSlashIndex);
21+
const lastDotIndex = filePath.lastIndexOf(".");
22+
const ext = filePath.slice(lastDotIndex);
23+
24+
// https://www.google.com/search?q=slice+mdn
25+
2226

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

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,19 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
77
// Try breaking down the expression and using documentation to explain what it means
88
// It will help to think about the order in which expressions are evaluated
99
// Try logging the value of num and running the program several times to build an idea of what the program is doing
10+
11+
12+
//ANSWERS:
13+
// Num represents a random whole number(integers). In which in this case it can be between 1 to 100.
14+
//Now let me break it down;
15+
16+
//This const minimum = 1; and this const maximum = 100; represent the range from which i want my random numbers to come from.
17+
18+
//This command Math.random() generates a random decimal number from 0(being inclusive) to 1(but not inclusing 1) e.g 0.23, 0.87, 0.001 or 0.999 but it will never generate 1.
19+
// This command (maximum - minimum + 1) is a calculation of the Maximum and Minimum number i.e, 100-1+1=100
20+
// This command Math.floor helps to remove any decimal point and round numbers down to the nearest whole number. e.g from 45.9 to 45
21+
// This command +Minimum helps to add the minimum number in our range inorder to increase the numbers to 100(incusive)
22+
23+
console.log (num)
24+
25+
//After logging and running num, I had these series of numbers: 12, 66, 36,64,9,91....

0 commit comments

Comments
 (0)