From 2d865ae24a23cad79e10672e020b6f8ac01212c0 Mon Sep 17 00:00:00 2001 From: Maryam Janjua Date: Fri, 26 Jun 2026 10:57:16 +0100 Subject: [PATCH 1/6] print desired Initials --- Sprint-1/1-key-exercises/1-count.js | 4 ++++ Sprint-1/1-key-exercises/2-initials.js | 3 ++- Sprint-1/1-key-exercises/3-paths.js | 12 ++++++++++-- prep/variables.js | 12 ++++++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 prep/variables.js diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6e..4d966e6cd8 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,3 +4,7 @@ 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 +/* +In line 3, it firstly execute count + 1 i.e 1 and then new value of count is store into variable count. +The value of count is initially 0 and then in line three it added by 1 so new value of count becomes 1. +*/ \ No newline at end of file diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f6175..1f5c553b3a 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -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 diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28e..1ca7aaba98 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -17,7 +17,15 @@ 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 lastindex1 = filePath.lastIndexOf("/"); +const dir1 = filePath.slice(0,lastindex1); +console.log(`The variable contains directory path of a file: ${dir1}`); +const dir = filePath.slice(0,44); +console.log(`This variable stores directory path of a file: ${dir}`); +//I did from both ways just to clear my concepts. + +const lastext = filePath.lastIndexOf("/"); +const ext = filePath.slice(lastext+5); +console.log(`This is extension part of a file: ${ext}`); // https://www.google.com/search?q=slice+mdn \ No newline at end of file diff --git a/prep/variables.js b/prep/variables.js new file mode 100644 index 0000000000..647889b675 --- /dev/null +++ b/prep/variables.js @@ -0,0 +1,12 @@ +/* +let num = 10; +let num = 20; +console.log(num); */ + +//declaration + +const greetings = 'Hello'; +const name = 'Maryam'; +const greet = '${greetings}, ${name}'; + +console.log(greet); \ No newline at end of file From 5e52076bf79248c5ec8214a5dcb958fed0918008 Mon Sep 17 00:00:00 2001 From: Maryam Janjua Date: Fri, 26 Jun 2026 11:02:01 +0100 Subject: [PATCH 2/6] Solved Exercise Math.floor and Math.random --- Sprint-1/1-key-exercises/4-random.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aabb..40d1954978 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -2,8 +2,16 @@ 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 + +/* +The num is a variable that hold a random variable every time we run the code it gives us a different random number. +In the above expression, firstly it will solve the parenthesis part i.e maximum - minimum +1. +i.e, (100 - 1 +1)-> 100 then it will evaluate Math.random, Math.random generate any number from 0-1 and it will multiply by +100 and added by minimum value i.e 1. Math.floor makes the value round if it is in decimal. +*/ \ No newline at end of file From 9dcebe99f3356330dabe9d22f645cc152af2674a Mon Sep 17 00:00:00 2001 From: Maryam Janjua Date: Fri, 26 Jun 2026 11:15:52 +0100 Subject: [PATCH 3/6] Erros Identified for all file of Sprint-1 --- Sprint-1/1-key-exercises/3-paths.js | 2 +- Sprint-1/2-mandatory-errors/0.js | 6 +++-- Sprint-1/2-mandatory-errors/1.js | 7 +++++- Sprint-1/2-mandatory-errors/2.js | 12 ++++++++-- Sprint-1/2-mandatory-errors/3.js | 17 +++++++++++++- Sprint-1/2-mandatory-errors/4.js | 8 +++++-- .../1-percentage-change.js | 15 +++++++++++- .../3-mandatory-interpret/2-time-format.js | 15 ++++++++---- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 23 +++++++++++++++++++ 9 files changed, 91 insertions(+), 14 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index 1ca7aaba98..75822862f7 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -19,7 +19,7 @@ console.log(`The base part of ${filePath} is ${base}`); const lastindex1 = filePath.lastIndexOf("/"); const dir1 = filePath.slice(0,lastindex1); -console.log(`The variable contains directory path of a file: ${dir1}`); +console.log(`The variable contains directory path of a file: ${dir1}`); const dir = filePath.slice(0,44); console.log(`This variable stores directory path of a file: ${dir}`); //I did from both ways just to clear my concepts. diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f7..e094376428 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 +//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? + +//As age was constant there we can't change the value of age like this. I made age let so it can change the value of age. \ No newline at end of file diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea76..e906986ed4 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -1,4 +1,9 @@ // trying to create an age variable and then reassign the value by 1 -const age = 33; +let age = 33; age = age + 1; +console.log(age); + +/*As age was constant here we can't change the value of age like this. +because in line 4, the value of age is incremented by 1 and assigning again to age but if variable is const we can't change. +I made age let so I can change the value of age.*/ diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831d..b3c2955d56 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -1,5 +1,13 @@ // Currently trying to print the string "I was born in Bolton" but it isn't working... // what's the error ? - -console.log(`I was born in ${cityOfBirth}`); const cityOfBirth = "Bolton"; +console.log(`I was born in ${cityOfBirth}`); + +/* +It a reference error, we cannot access cityOfBirth before initializing it. We are trying to fetch a +value of cityOfbirth without declaring it. The interpreter first runs the line 1 i.e console.log one +and try to find a value but its not declare and it will give a error. Though we have declare is in line 2 +but js is an interpreted language that interpret line by line and runs the code. +The cityOfBirth is in locked state right now js couldn't access until reaches to it. +Right now it is in temporal locked state. +*/ diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884db..ab145325d5 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -1,5 +1,10 @@ -const cardNumber = 4533787178994213; +const cardNumber = "4533787178994213"; const last4Digits = cardNumber.slice(-4); +console.log(last4Digits); + +//const cardNumber = 4533787178994213; +//const lastdig = cardNumber.toString().slice(-4); +//console.log(lastdig); // The last4Digits variable should store the last 4 digits of cardNumber // However, the code isn't working @@ -7,3 +12,13 @@ const last4Digits = cardNumber.slice(-4); // Then run the code and see what error it gives. // Consider: Why does it give this error? Is this what I predicted? If not, what's different? // Then try updating the expression last4Digits is assigned to, in order to get the correct value + +/* +Slice is a string method we are using it on number. +We can convert the number into string and then apply slice() method to retrieve last four digits or simply we +can declare number as a string using quotes. +Run a code : It gives TypeError and js gives this error when method/operation isn't valid for particular data +type using. +I got the idea of data type that slice() method can't use for this data type. +I attempt it by both ways I mentioned above. +*/ diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 5f86c730bc..f6096da2bb 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,6 @@ -const 12HourClockTime = "8:53pm"; -const 24hourClockTime = "20:53"; +const HourClockTime12 = "8:53pm"; +const hourClockTime24 = "20:53"; + +/*The variable name cannot start with number. It can begin with _, $ or a letter. +I fixed it by renaming the variable names. +*/ \ No newline at end of file diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index e24ecb8e18..7808aa7e4f 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -2,7 +2,7 @@ let carPrice = "10,000"; let priceAfterOneYear = "8,543"; carPrice = Number(carPrice.replaceAll(",", "")); -priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); +priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," , "")); const priceDifference = carPrice - priceAfterOneYear; const percentageChange = (priceDifference / carPrice) * 100; @@ -12,11 +12,24 @@ console.log(`The percentage change is ${percentageChange}`); // Read the code and then answer the questions below // a) How many function calls are there in this file? Write down all the lines where a function call is made +/* +replaceAl() : In line 4, replaceAll(",", "") and in line 5, replaceAll("," "") +Number() : In line 4, Number(carPrice.replaceAll(",", "")) and in line 5, Number(priceAfterOneYear.replaceAll("," "") +console.log: In line 10, console.log(`The percentage change is ${percentageChange}`); + */ // b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem? +//Basically, the error is coming from line 5. It missed the , between two values. +//priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," , "")); // c) Identify all the lines that are variable reassignment statements +//line 4 and line 5 // d) Identify all the lines that are variable declarations +//line 1, line 2, line 7 and line 8 // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? +/* Number(carPrice.replaceAll(",","")) let's breakdown this to understand. +carPrice.replaceAll(",","") -> replaces , and it becomes 1000 +Number("1000") converts string to a number -> 1000. +*/ diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 47d2395587..53c81cca2d 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -1,5 +1,5 @@ -const movieLength = 8784; // length of movie in seconds - +//const movieLength = 8784; // length of movie in seconds +const movieLength = 9893; const remainingSeconds = movieLength % 60; const totalMinutes = (movieLength - remainingSeconds) / 60; @@ -12,14 +12,21 @@ console.log(result); // For the piece of code above, read the code and then answer the following questions // a) How many variable declarations are there in this program? +//six // b) How many function calls are there? +// 1 i.e console.log // c) Using documentation, explain what the expression movieLength % 60 represents // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators +// This is a reminder operator. It divides one number by another and gives a reminder. // d) Interpret line 4, what does the expression assigned to totalMinutes mean? - +/* const totalMinutes = (movieLength - remainingSeconds) / 60 +Firstly it will evaluate bracket i.e (movieLength - remainingSeconds) and then divide the value by 60. +*/ // e) What do you think the variable result represents? Can you think of a better name for this variable? - +// The result represents the how long the movie is, in hours, minutes and seconds. It can named as MovieDuration. // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer +// Yes, I changed the value of movieLength and it worked. The movieLength is the variable used in calculating other +// values and to evaluate the total length of movie. \ No newline at end of file diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 60c9ace69a..ed73538aad 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -25,3 +25,26 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" +/*line 3-6. +const penceStringWithoutTrailingP = penceString.substring( + 0, + penceString.length - 1 +) : calculate the length and then subtract 1,length is 4-1=3 , and extract substring 0 to 3 i.e 399 +/* +line 8.Padstart puts zero in beginning until it meets the desire length. The length is 3 and string length is already 3, so it remained unchanged. +paddedPenceNumberString = "399" +line 9-12. +const pounds = paddedPenceNumberString.substring( + 0, + paddedPenceNumberString.length - 2 +); paddedPenceNumberString.length - 2: 3-2=1 -> paddedPenceNumberString.substring(0,1)-> pounds="3" +line 14-16. +const pence = paddedPenceNumberString + .substring(paddedPenceNumberString.length - 2) + .padEnd(2, "0"); +(paddedPenceNumberString.length - 2)-> 3-2 = 1 -> substring(1).padEnd(2,"0")-> 99, the length is already two. +pence ="99" + +console.log(`£${pounds}.${pence}`); +£3.99 +*/ From aef0c0751c0d745c8aee50e5808c76da54874d25 Mon Sep 17 00:00:00 2001 From: Maryam Janjua Date: Fri, 26 Jun 2026 11:21:11 +0100 Subject: [PATCH 4/6] Did Mandatory Intepret tasks on 3 files of sprint 1 --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index ed73538aad..db7d1c3d20 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -30,21 +30,24 @@ const penceStringWithoutTrailingP = penceString.substring( 0, penceString.length - 1 ) : calculate the length and then subtract 1,length is 4-1=3 , and extract substring 0 to 3 i.e 399 -/* + line 8.Padstart puts zero in beginning until it meets the desire length. The length is 3 and string length is already 3, so it remained unchanged. paddedPenceNumberString = "399" + line 9-12. const pounds = paddedPenceNumberString.substring( 0, paddedPenceNumberString.length - 2 ); paddedPenceNumberString.length - 2: 3-2=1 -> paddedPenceNumberString.substring(0,1)-> pounds="3" -line 14-16. +l +ine 14-16. const pence = paddedPenceNumberString .substring(paddedPenceNumberString.length - 2) .padEnd(2, "0"); (paddedPenceNumberString.length - 2)-> 3-2 = 1 -> substring(1).padEnd(2,"0")-> 99, the length is already two. pence ="99" +line 18. console.log(`£${pounds}.${pence}`); £3.99 */ From d89f407de80c8649ddaf81a95b489425adfc8b13 Mon Sep 17 00:00:00 2001 From: Maryam Janjua Date: Fri, 26 Jun 2026 12:31:24 +0100 Subject: [PATCH 5/6] Did chrome tasks --- Sprint-1/4-stretch-explore/chrome.md | 11 ++++++----- Sprint-1/4-stretch-explore/objects.md | 10 +++++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md index e7dd5feafe..9acf597817 100644 --- a/Sprint-1/4-stretch-explore/chrome.md +++ b/Sprint-1/4-stretch-explore/chrome.md @@ -8,11 +8,12 @@ Just like the Node REPL, you can input JavaScript code into the Console tab and Let's try an example. In the Chrome console, -invoke the function `alert` with an input string of `"Hello world!"`; +invoke the function `alert` with an input string of `"Hello world!"`; it displays hello world in a alert box -What effect does calling the `alert` function have? +What effect does calling the `alert` function have? the alert function forces browser to display a message or a warning. Now try invoking the function `prompt` with a string input of `"What is your name?"` - store the return value of your call to `prompt` in an variable called `myName`. - -What effect does calling the `prompt` function have? -What is the return value of `prompt`? +Prompt("what is your name?"), it pops-up a dialog box where I enter my name. +I saved my name in a variable myName and I called the prompt function, it gives my name. +What effect does calling the `prompt` function have? by prompt you can write/give your input or user can cancel it +What is the return value of `prompt`? name user have input or null in case of cancel. diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md index 0216dee56a..a10ee670be 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -4,13 +4,17 @@ In this activity, we'll explore some additional concepts that you'll encounter i Open the Chrome devtools Console, type in `console.log` and then hit enter -What output do you get? +What output do you get? -> it says there a function log inside console. -Now enter just `console` in the Console, what output do you get back? +Now enter just `console` in the Console, what output do you get back? it says there a function log inside console. -Try also entering `typeof console` +Try also entering `typeof console` ->object, console is a built-in object. Answer the following questions: What does `console` store? +It doesn't store anything, It is a debugging object that enables you to interact with browser's developers tools. What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? +console.log -> it prints normal messages +console.assert -> it is conditional debugger, it checks the condition. If its true it gives nothing and if its false it displays message in console. +The dot . it means to access inside the object. \ No newline at end of file From c750fa3f98c10f7e1a216b90b26d96f932b9dcaa Mon Sep 17 00:00:00 2001 From: Maryam Janjua Date: Fri, 26 Jun 2026 22:47:34 +0100 Subject: [PATCH 6/6] Remove prep/variables.js --- prep/variables.js | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 prep/variables.js diff --git a/prep/variables.js b/prep/variables.js deleted file mode 100644 index 647889b675..0000000000 --- a/prep/variables.js +++ /dev/null @@ -1,12 +0,0 @@ -/* -let num = 10; -let num = 20; -console.log(num); */ - -//declaration - -const greetings = 'Hello'; -const name = 'Maryam'; -const greet = '${greetings}, ${name}'; - -console.log(greet); \ No newline at end of file