Skip to content

Commit 84027f2

Browse files
committed
Fixed PR review
1 parent 1c7d558 commit 84027f2

File tree

9 files changed

+33
-17
lines changed

9 files changed

+33
-17
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ 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-
//Line 3 of the code assigns a value to the declared variable count.
7+
//Line 3 of the code reassigns a value to the declared variable count.
8+
// the programming term for this is called increment
89
// The = sign is an assignment operator, without line 3, the declared variable wil be undefined.

Sprint-1/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-
let initials = `${firstName[0]}+${middleName}+${lastName}`;
8+
let initials = `${firstName[0]}${middleName[0]}${lastName[0]}`;
9+
console.log(initials); //CJK
910

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

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@
99

1010
// (All spaces in the "" line should be ignored. They are purely for formatting.)
1111

12-
const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt";
12+
const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/package.json";
1313
const lastSlashIndex = filePath.lastIndexOf("/");
1414
const base = filePath.slice(lastSlashIndex + 1);
1515
console.log(`The base part of ${filePath} is ${base}`);
1616

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
19+
const lastDotIndex = filePath.lastIndexOf(".");
20+
const dir = filePath.slice(0, lastSlashIndex);
21+
const ext = filePath.slice(lastDotIndex + 1);
22+
console.log(dir);
23+
console.log(ext);
1924

20-
const dir =filePath.slice(0,filePath.length-base.length-1) ;
21-
const ext = filePath.slice(-3);
22-
23-
// https://www.google.com/search?q=slice+mdn
25+
// https://www.google.com/search?q=slice+mdn

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Currently trying to print the string "I was born in Bolton" but it isn't working...
2-
3-
// JavaScript is single-threaded because it executes tasks in a single flow using a call stack. The function was called before it was declared,
2+
3+
// JavaScript is single-threaded because it executes tasks in a single flow using a call stack. The function was called before it was declared,
44
// It was also declared with const, which can not be hoisted to the top, like var.
55
// this result to undefined.
66

Sprint-1/3-mandatory-interpret/1-percentage-change.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ console.log(`The percentage change is ${percentageChange}`);
1919
// 3. line 10 console.log() that logs the result to the console
2020

2121
// b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem?
22-
// The error in this code is coming from line 5. The wrong use of the replaceAll syntax without a separator.
22+
// The error in this code is coming from line 5. The wrong use of the
23+
// replaceAll method without a comma between the pattern and replacement in the function argument.
2324
// I will fix this problem by reading the documentation, to see the right way the syntax should be written.
2425
//Then i will add the comma where necessary
2526

2627
// c) Identify all the lines that are variable reassignment statements
27-
// line 4 and 5 are variable reassignment
28+
// line 4 and 5 are variable reassignment
2829

2930
// d) Identify all the lines that are variable declarations
30-
// line 1,2,7,8 are all variable declaration
31+
// line 1,2,7,8 are all variable declaration
3132

3233
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
33-
// this expression replaces the comma at the string with an empty string and the convert the string data type to a number data type
34+
// this expression replaces the comma at the string with an empty string and the convert the string data type to a number data type

Sprint-1/3-mandatory-interpret/2-time-format.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ console.log(result);
1414
// a) How many variable declarations are there in this program?
1515
// there are 6 variable declaration.
1616

17-
1817
// b) How many function calls are there?
1918
// One function call
2019

@@ -29,7 +28,7 @@ console.log(result);
2928

3029
// e) What do you think the variable result represents? Can you think of a better name for this variable?
3130
// the variable result represent total movie duration in hours,minute and seconds.
32-
// const=movieLength
31+
// const=movieDuration
3332

3433
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
3534
// this code works for all movie length and integer values.

Sprint-1/4-stretch-explore/chrome.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ What effect does calling the `prompt` function have?
2323
it invokes a modal window, and allows me to enter an input value
2424
What is the return value of `prompt`?
2525
it returns the value i entered "Edak"
26+
It will return null.

Sprint-1/4-stretch-explore/objects.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ What does the syntax `console.log` or `console.assert` mean? In particular, what
2222
console.log: Output a message to the console
2323

2424
console.assert: Log an error message to the console if the first argument is false.
25-
`.` console is the class the . helps you to access the methods or properties of the class console.
25+
`.` the console stored methods.

Sprint-3/2-practice-tdd/count.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
function countChar(stringOfCharacters, findCharacter) {
2-
return 5
2+
let count=0;
3+
for(let i=0; i<stringOfCharacters.length; i++){
4+
5+
if(stringOfCharacters[i]===findCharacter){
6+
count++;
7+
}else{
8+
return 0
9+
}
10+
11+
}
12+
return count;
313
}
414

15+
516
module.exports = countChar;

0 commit comments

Comments
 (0)