diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6e..b573b10355 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -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. diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f6175..0238a71c60 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -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 diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28e..69db49a037 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -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 \ No newline at end of file +// https://www.google.com/search?q=slice+mdn diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aabb..ded7861933 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -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 diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f7..8e3cf85163 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/2-mandatory-errors/0.js @@ -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? \ No newline at end of file +We don't want the computer to run these 2 lines - how can we solve this problem? +*/ diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index e24ecb8e18..50c80e9eac 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -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. +*/ diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 47d2395587..aa8b9d3f6b 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -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. +*/ diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 60c9ace69a..2bea1f9a57 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -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" +*/