Skip to content

Commit 2135afb

Browse files
committed
file javas fundamentals
1 parent 8b470cc commit 2135afb

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ 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-
const 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+
console.log(initials);

Sprint-2/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 ext = filePath.slice(filePath.lastIndexOf(".") + 1);
2222

23-
// https://www.google.com/search?q=slice+mdn
23+
console.log(dir);
24+
console.log(ext);
25+
26+
// https://www.google.com/search?q=slice+mdn

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ 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+
// num represents a random integer between the minimum and maximum values (inclusive).
11+
// The expression Math.random() generates a random decimal number between 0 (inclusive) and 1 (exclusive).
12+
// By multiplying this value by (maximum - minimum + 1), we scale it to the desired range.
13+
// The Math.floor() function then rounds this value down to the nearest whole number, ensuring we get an integer.
14+
// Finally, we add the minimum value to shift the range to start from the minimum instead of 0.

0 commit comments

Comments
 (0)