Skip to content

Commit 3aed680

Browse files
committed
Finished the first 4 key exercises
1 parent d28242a commit 3aed680

4 files changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
let count = 0;
2+
3+
count = count + 1;
4+
5+
// 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
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const firstName = "Creola";
2+
const middleName = "Katherine";
3+
const lastName = "Johnson";
4+
5+
// Declare a variable called initials that stores the first character of each string.
6+
// This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution.
7+
8+
const initials = ``;
9+
10+
// https://www.google.com/search?q=get+first+character+of+string+mdn
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// The diagram below shows the different names for parts of a file path on a Unix operating system
2+
3+
// ┌─────────────────────┬────────────┐
4+
// │ dir │ base │
5+
// ├──────┬ ├──────┬─────┤
6+
// │ root │ │ name │ ext │
7+
// " / home/user/dir / file .txt "
8+
// └──────┴──────────────┴──────┴─────┘
9+
10+
// (All spaces in the "" line should be ignored. They are purely for formatting.)
11+
12+
const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt";
13+
const lastSlashIndex = filePath.lastIndexOf("/");
14+
const base = filePath.slice(lastSlashIndex + 1);
15+
console.log(`The base part of ${filePath} is ${base}`);
16+
17+
// Create a variable to store the dir part of the filePath variable
18+
// Create a variable to store the ext part of the variable
19+
20+
const dir = ;
21+
const ext = ;
22+
23+
// https://www.google.com/search?q=slice+mdn
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const minimum = 1;
2+
const maximum = 100;
3+
4+
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
5+
6+
// In this exercise, you will need to work out what num represents?
7+
// Try breaking down the expression and using documentation to explain what it means
8+
// It will help to think about the order in which expressions are evaluated
9+
// 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)