Skip to content
Open
1 change: 1 addition & 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,4 @@ 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 adding 1 to that value of count variable, then making that new value to be the current count variable.
2 changes: 1 addition & 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,7 @@ 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[0] + middleName[0] + lastName[0];

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

6 changes: 3 additions & 3 deletions Sprint-1/1-key-exercises/3-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ 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 = ;
const dir = filePath.slice (0,lastSlashIndex +1);
const ext = filePath.slice (filePath.lastIndexOf ("."));

// https://www.google.com/search?q=slice+mdn
// https://www.google.com/search?q=slice+mdn
2 changes: 1 addition & 1 deletion Sprint-1/1-key-exercises/4-random.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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
Expand Down
4 changes: 3 additions & 1 deletion Sprint-1/2-mandatory-errors/0.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/*
This is just an instruction for the first activity - but it is just for human consumption
We don't want the computer to run these 2 lines - how can we solve this problem?
We don't want the computer to run these 2 lines - how can we solve this problem?
*/
10 changes: 10 additions & 0 deletions Sprint-1/3-mandatory-interpret/1-percentage-change.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ console.log(`The percentage change is ${percentageChange}`);
// d) Identify all the lines that are variable declarations

// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?

/*
a) There are 5 calls made:
carPrice = Number(carPrice.replaceAll(",", ""));
priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""))
b) Error on line 5 for "," it is missing the seperating , between "," and "".
c) 4 and 5
d) 1 and 2, 7 and 8,
e) It removes the , from the string and replaces it with nothing. Used to help change the string into a number with the "Number" function.
*/
9 changes: 9 additions & 0 deletions Sprint-1/3-mandatory-interpret/2-time-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,12 @@ console.log(result);
// e) What do you think the variable result represents? Can you think of a better name for this variable?

// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
/*
a) There are 6: movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, result.
b) There is one: console.log.
c) It is taking the movieLength and doing a remainder that is showing what is left after the vaule has been divided, in this case wil be 84.
I found the info here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Remainder
d) It is removing any extra seconds from the division by 60 so that is is showing as whole numbers without decimals.
e) Result is showing the movies duration but broken down to hours:minutes:seconds, I think it should be movieDuration to help describe it better.
f) Yes, it does work to show the lenght even if it is only in one section, though it does show values of 0, could clean it up to show nothing.
*/
8 changes: 8 additions & 0 deletions Sprint-1/3-mandatory-interpret/3-to-pounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ console.log(`£${pounds}.${pence}`);

// To begin, we can start with
// 1. const penceString = "399p": initialises a string variable with the value "399p"
/*
3-6. It is taking the vaule from pencestring and using substring to return part of the string, by -1 so from the end resualting in "399"
8. It is now adding "0" infront of vaule if the vaule is under 3 characters in size.
9-12. Using the substring function to reduce the size of the vaule to just 2 characters.
14-16. Taking the value from paddedPenceNumberString and this time with substring, only showing the last 2 characters in teh value.
Then with using .padEnd it ensures that 2 characters are shown with 0 being there is nothing is there.
18. howing the resualt of the code starting with a "£" then the value of "pounds" then a "." and lastly value of "pence"
*/
Loading