Skip to content

Commit 7f49f8b

Browse files
author
Enice-Codes
committed
completed sprint key excercises
1 parent b31a586 commit 7f49f8b

4 files changed

Lines changed: 19 additions & 7 deletions

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,10 @@ let count = 0;
22

33
count = count + 1;
44

5-
// Line 1 is a variable declaration, creating the count variable with an initial value of 0
5+
// Line 3 reassigns the value of count.
6+
// The expression on the right side (count + 1) is evaluated first using the current value of count.
7+
// The = assignment operator then stores the result back into the count variable, replacing its previous value.
8+
9+
10+
// Line 1 is a variablbe declaration, creating the count variable with an initial value of 0
611
// Describe what line 3 is doing, in particular focus on what = is doing

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ 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
11-

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// The diagram below shows the different names for parts of a file path on a Unix operating system
22

3-
// ┌─────────────────────┬────────────┐
43
// │ dir │ base │
54
// ├──────┬ ├──────┬─────┤
65
// │ root │ │ name │ ext │
@@ -17,7 +16,10 @@ console.log(`The base part of ${filePath} is ${base}`);
1716
// Create a variable to store the dir part of the filePath variable
1817
// Create a variable to store the ext part of the variable
1918

20-
const dir = ;
21-
const ext = ;
19+
const dir = filePath.slice (0,lastSlashIndex);
20+
const ext = base.slice(base.lastIndexOf(".") + 1);
2221

23-
// https://www.google.com/search?q=slice+mdn
22+
// https://www.google.com/search?q=slice+mdn
23+
24+
// dir = everything before the last /
25+
// ext = everything from the last . to the end of the string (.txt)ssss

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,11 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
55

66
// In this exercise, you will need to work out what num represents?
77
// Try breaking down the expression and using documentation to explain what it means
8+
9+
//num is a random number between 1 and 100
10+
11+
// Method.floor generates a random number between 0 and 1 to nearest interger (whole number)
12+
//Math.random generates a decimal number between 0 and 1 .
13+
814
// It will help to think about the order in which expressions are evaluated
915
// Try logging the value of num and running the program several times to build an idea of what the program is doing

0 commit comments

Comments
 (0)