Skip to content

Commit 42df165

Browse files
AlanGit-debug2604debug2604
authored andcommitted
modified Key exercises files 1,2,and3
1 parent d28242a commit 42df165

4 files changed

Lines changed: 45 additions & 38 deletions

File tree

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
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
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 = firstName.charAt(0) + middleName.charAt(0) + lastName.charAt(0);
9+
console.log(initials)
10+
11+
// https://www.google.com/search?q=get+first+character+of+string+mdn
Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
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-
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 = filePath.slice(0,lastSlashIndex);
21+
const ext = filePath.slice(filePath.lastIndexOf("."));
22+
23+
console.log(dir);
24+
console.log(ext);
25+
2326
// https://www.google.com/search?q=slice+mdn

‎Sprint-2/2-mandatory-errors/0.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
This is just an instruction for the first activity - but it is just for human consumption
2-
We don't want the computer to run these 2 lines - how can we solve this problem?
1+
//This is just an instruction for the first activity - but it is just for human consumption
2+
//We don't want the computer to run these 2 lines - how can we solve this problem?
3+
//By adding two slashes

‎Sprint-2/2-mandatory-errors/1.js‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// trying to create an age variable and then reassign the value by 1
2-
3-
const age = 33;
4-
age = age + 1;
1+
// trying to create an age variable and then reassign the value by 1
2+
3+
const age = 33;
4+
age == age + 1;
5+
6+
console.log(age)

0 commit comments

Comments
 (0)