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
3 changes: 2 additions & 1 deletion Sprint-1/1-key-exercises/1-count.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ let count = 0;

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 increase the value of count by 1 and save the value into count variable.
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 = ``;
// this variable storage the first character of each string
let initials = firstName.charAt(0) + middleName.charAt(0) + lastName.charAt(0);

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

11 changes: 9 additions & 2 deletions Sprint-1/1-key-exercises/3-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ console.log(`The base part of ${filePath} is ${base}`);
// Create a variable to store the dir part of the filePath variable
// Create a variable to store the ext part of the variable

const dir = ;
const ext = ;
// dir: everything before the last slash
const dir = filePath.slice(0, lastSlashIndex);

// ext: everything after the last dot in the base
const lastDotIndex = base.lastIndexOf(".");
const ext = base.slice(lastDotIndex + 1);

console.log(`Dir: ${dir}`);
console.log(`Ext: ${ext}`);

// https://www.google.com/search?q=slice+mdn
9 changes: 9 additions & 0 deletions Sprint-1/1-key-exercises/4-random.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@ const maximum = 100;

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


// 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


// Math.random() generates random number . up to 0 but not include 1
// this (maximum - minimum + 1) gives the range of generated random number
// and this function Math.floor() make the number to the nearest integer number.
// num is a random integer between minimum (1) and maximum (100), including 1 & 100

console.log(num);
Loading