Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Sprint-1/1-key-exercises/1-count.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ count = count + 1;

// Line 1 is a variable declaration, creating the count variable with an initial value of 0
// Describe what line 3 is doing, in particular focus on what = is doing

//Line 3 is a statement. Here we reassign the value of count from 0 to 1 by adding value one to it
3 changes: 2 additions & 1 deletion Sprint-1/1-key-exercises/2-initials.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ let lastName = "Johnson";
// Declare a variable called initials that stores the first character of each string.
// This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution.

let initials = ``;
let initials = firstName.charAt(0)+middleName.charAt(0)+lastName.charAt(0);
console.log(initials);

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

16 changes: 14 additions & 2 deletions Sprint-1/1-key-exercises/3-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,21 @@ const base = filePath.slice(lastSlashIndex + 1);
console.log(`The base part of ${filePath} is ${base}`);

// Create a variable to store the dir part of the filePath variable
function dirString(){
const dirName = filePath.slice(1,lastSlashIndex);
return dirName;
}

// Create a variable to store the ext part of the variable
function extString(){
const lastDotIndex = filePath.lastIndexOf(".");
const extName = filePath.slice(lastDotIndex);
return extName;
}

const dir = ;
const ext = ;
const dir = dirString(filePath);
const ext = extString(filePath);
console.log(dir);
console.log(ext);

// https://www.google.com/search?q=slice+mdn
11 changes: 10 additions & 1 deletion Sprint-1/1-key-exercises/4-random.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
const minimum = 1;
const maximum = 100;

const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
console.log(num);

// In this exercise, you will need to work out what num represents?
// Try breaking down the expression and using documentation to explain what it means
// It will help to think about the order in which expressions are evaluated
// Try logging the value of num and running the program several times to build an idea of what the program is doing

//In the declaration of num, we can break it down to below:

//1. A randon number, which is with decimals between 0 and 1, is created by method Math.random()
//2. The random number in step 1 is multipled by 100. That makes an number with decimals.
//3. The method Math.floor grounded the number in step 2 down to a whole number between 0 - 99.
//4. The number from step 3 is added 1, so it makes a whole number between 1-100.

//I think the overall javascript code here is to make a random whole number between 1-100.
Loading