Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 1 deletion Sprint-1/1-key-exercises/3-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ console.log(`The base part of ${filePath} is ${base}`);
// Create a variable to store the ext part of the variable

const dir = filePath.slice(1, lastSlashIndex);
const ext = base.split(".")[1];
const ext = base.slice(base.lastIndexOf(".") + 1);

// https://www.google.com/search?q=slice+mdn
8 changes: 4 additions & 4 deletions Sprint-1/1-key-exercises/4-random.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
// The num variable will evaluate to a random number between the minimum and maximum values

// Math.random()
// Random decimal number (0 - 1)
// Random decimal number [0, 1)

// (maximum - minimum + 1)
// The size of the range

// Math.random() * (maximum - minimum + 1)
// Random decimal (0 - 100)
// Random decimal [0, 101)

// Math.floor(...)
// Rounds the result down to a whole number (0 - 99)
// Rounds the result down to a whole number [0, 100]

// Adding minimum shifts the range up, so the final result is between the minimum and maximum (1 - 100 inclusive)
// Adding minimum shifts the range up, so the final result is between the minimum and maximum [1, 100]
6 changes: 3 additions & 3 deletions Sprint-1/3-mandatory-interpret/3-to-pounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const pounds = paddedPenceNumberString.substring(
);

// 5. extracts the pence part by taking the last two digits, and pads with trailing zeroes if needed
const pence = paddedPenceNumberString
.substring(paddedPenceNumberString.length - 2)
.padEnd(2, "0");
const pence = paddedPenceNumberString.substring(
paddedPenceNumberString.length - 2
);

// 6. formats and prints the result as a pounds and pence string
console.log(`£${pounds}.${pence}`);
Expand Down