-
-
Notifications
You must be signed in to change notification settings - Fork 245
London | Sep-2025 | Gislaine Della Bella | Structuring and Testing Data | Sprint-1 #739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9fb5c1d
6732232
e9af9ad
4d88962
8a5ee4b
9f1d381
9caae05
9aa96a7
9cc5c5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,20 @@ | ||
|
|
||
|
|
||
| // 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. | ||
| // https://www.google.com/search?q=get+first+character+of+string+mdn | ||
|
|
||
| let firstName = "Creola"; | ||
| let middleName = "Katherine"; | ||
| 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 = ``; | ||
|
|
||
| // https://www.google.com/search?q=get+first+character+of+string+mdn | ||
| let initials= `${firstName.charAt(0)}${middleName.charAt(0)}${lastName.charAt(0)}`; | ||
| //test | ||
| //let initialsSecond = `${firstName.charAt(3)} ${middleName.charAt(2)} ${lastName.charAt(4)}`; | ||
|
|
||
| console.log (initials); | ||
|
|
||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,16 +8,22 @@ | |
| // └──────┴──────────────┴──────┴─────┘ | ||
|
|
||
| // (All spaces in the "" line should be ignored. They are purely for formatting.) | ||
|
|
||
| //home / user /dir / file.txt; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as previous comment, is this and everything after line 27 needed for the solution? If not, let's remove it to keep the PR focused.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ;) done |
||
| const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt"; | ||
| const lastSlashIndex = filePath.lastIndexOf("/"); | ||
| const lastSlashIndex = filePath.lastIndexOf("/"); //=index 47 / | ||
| const base = filePath.slice(lastSlashIndex + 1); | ||
| console.log(`The base part of ${filePath} is ${base}`); | ||
|
|
||
|
|
||
|
|
||
| // Create a variable to store the dir part of the filePath variable | ||
| const dir = filePath.slice(0, lastSlashIndex + 1); | ||
| console.log(`The directory part is: ${dir}`); | ||
|
|
||
| // Create a variable to store the ext part of the variable | ||
| const lastDotIndex = filePath.lastIndexOf("."); // look for the last Dot | ||
| const extPart = filePath.slice(lastDotIndex + 1); | ||
| console.log(`The extension part is: ${extPart}`); | ||
|
|
||
| const dir = ; | ||
| const ext = ; | ||
| // https://www.google.com/search?q=slice+mdn | ||
|
|
||
| // https://www.google.com/search?q=slice+mdn | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,21 @@ const minimum = 1; | |
| const maximum = 100; | ||
|
|
||
| const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; | ||
| //const num = Math.floor(Math.random() * (maximum - minimum)) + minimum; | ||
| console.log(num); | ||
|
|
||
| // In this exercise, you will need to work out what num represents? | ||
|
|
||
| //Num represents a random number between 1 to 100 inclde both becasue we are adding 1 | ||
|
|
||
| // Try breaking down the expression and using documentation to explain what it means | ||
|
|
||
| //(maximum - minimum + 1) = get maximum number 100 extract the minimum 1 add +1 to incluide 100. | ||
| //+ minimum add 1 | ||
|
|
||
| //math.radom = gets randm number between 0 and 1 but never 1 so we add +1 to incluide 1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're onto something here, but I think you're mixing two ideas.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Della-Bella you might have skipped this comment
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hi Jennete, I modified the code without the -1 and got it would never get 100 random would go up to 99. got t know. So the +1 is essential to the maximum value can be 100. thank you |
||
| //Math.floor= will raounds donw to the nearest whole number | ||
|
|
||
|
|
||
| // 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| 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? | ||
| //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? | ||
| //coment the lines |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| // 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); | ||
|
|
||
| // error if we intend to change the value assing to a variable we need to use "LET" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| // 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}`); | ||
|
|
||
| // Error trying to use the variable "cityOfBirth"before declare it |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,18 @@ | ||
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.slice(-4); | ||
| //const cardNumber = 4533787178994213; | ||
| //const last4Digits = cardNumber.slice(-4); | ||
|
|
||
| // The last4Digits variable should store the last 4 digits of cardNumber | ||
| // However, the code isn't working | ||
| // Before running the code, make and explain a prediction about why the code won't work | ||
| // 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 | ||
|
|
||
|
|
||
| // it will not work becase Slice is a string methodo. | ||
| // To work here need to convert the number to string | ||
|
Comment on lines
+12
to
+13
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spot on!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, @jennethydyrova, for your time reviewing my work. Ib will remember about the extra and personal coments. Make the PR's clear ;) |
||
|
|
||
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.toString().slice(-4); | ||
|
|
||
| console.log(last4Digits); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,9 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| // const 12HourClockTime = "20:53"; | ||
| // const 24hourClockTime = "08:53"; | ||
|
|
||
| const hour12ClockTime = "20:53"; | ||
| const hour24ClockTime = "08:53"; | ||
|
|
||
| console.log(hour12ClockTime,hour24ClockTime); | ||
|
|
||
| // variable names can't start with nunmbers |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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,19 @@ 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 | ||
| // 3 functions: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Close! Double-check what makes something a function call. Look for the pattern: |
||
| // carPrice = Number(carPrice.replaceAll(",", "")); | ||
| // priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); | ||
| // const percentageChange = (priceDifference / carPrice) * 100; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this a function call? |
||
|
|
||
| // 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? | ||
| //Error was in line 5 missing a coman between the get to replace "" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo in comma |
||
|
|
||
| // c) Identify all the lines that are variable reassignment statements | ||
| // lines 4, 5 | ||
|
|
||
| // d) Identify all the lines that are variable declarations | ||
| // lines 1 and 2 , 7 and 8 | ||
|
|
||
| // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? | ||
| // it is converting the numbers prices to real numbers replace the commnas to empty string so takrs the commans out | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're on the right track but can you be more specific about:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you missed this comment. Your explanation just reads the line but doesn't explain what it actually does. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| const movieLength = 8784; // length of movie in seconds | ||
| const movieLength = 8784; // decaring length of movie in seconds | ||
|
|
||
| const remainingSeconds = movieLength % 60; | ||
| const remainingSeconds = movieLength % 60; // decalring the remaining seconds | ||
| const totalMinutes = (movieLength - remainingSeconds) / 60; | ||
|
|
||
| const remainingMinutes = totalMinutes % 60; | ||
|
|
@@ -12,14 +12,30 @@ 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? | ||
| // 4 on lines : 1, 3 and 6 and 9 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, variables are declared on lines 1, 3, 6, and 9, but are those all?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, this comment is not addressed. |
||
|
|
||
|
|
||
| // b) How many function calls are there? | ||
| //2 | ||
| // lines 4 and 7 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you might be confusing brackets in operations with function calls. You identified 2 function calls on lines 4 and 7 Let's check: Line 4: Are these actually function calls? What's the pattern for a function call? |
||
|
|
||
| // c) Using documentation, explain what the expression movieLength % 60 represents | ||
| // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators | ||
| // uUses the operator "Reminder". divinfding the month lenth by 60 ( minutes) to get homw many second reminds in the month lengh= | ||
| // 8784 / 60 = 146 minutes and remind 24 seconds letf | ||
|
Comment on lines
+24
to
+25
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good attempt! A few things to clarify:
|
||
|
|
||
|
|
||
| // d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
| // line 4 find how many total minutes has in the month lenght. | ||
| // first gets te toal seconds less the reminds sconds. it gives the results of total seconds and divides it | ||
| //by the 60 ( minutes) = results homw many minutes has in the total lenght or movieTotalLength | ||
| //8784 - 24 ==== 8760 | ||
| // 8760 / 60 equals 146 minutes | ||
|
|
||
| // e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
| // represents how long in time is the movie. could be caled= const timeMovie | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good thinking about naming! Look at how other variables are named in this code (like totalMinutes). Can you make "timeMovie" follow the same naming style? (Hint: in JS naming convention for variables usually follows
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe movieTotalLength |
||
|
|
||
| // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
| // i guess it wouldnt worrk for negative numbers but actualy evething envolves time is dificult to | ||
| //my mind explain. I need to search for more simples expamples to associete this Reminder operetar in time. | ||
| // this was a dificult mind flows to me :( | ||
|
Comment on lines
+39
to
+41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch on negative numbers!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ;) |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| const penceString = "399p"; | ||
| const penceString = "9p"; | ||
|
|
||
| const penceStringWithoutTrailingP = penceString.substring( | ||
| 0, | ||
|
|
@@ -25,3 +25,17 @@ console.log(`£${pounds}.${pence}`); | |
|
|
||
| // To begin, we can start with | ||
| // 1. const penceString = "399p": initialises a string variable with the value "399p" | ||
|
|
||
| //lines 3 to 6= we asing a variable "penceStringWithoutTrailingP". | ||
| //we use substring to start from index 0 and get the lenght 4 - 1 = 3 | ||
| // so sbtstring start form 0 and the length has 3 = 399 | ||
|
|
||
|
|
||
| // line 8. We declare variale "const paddedPenceNumberString" make sure the number number has least 3 digits | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You said padStart "makes sure the number has at least 3 digits", that's correct. But why do we need exactly 3 digits? Try running the code with penceString = "9p" and trace through what happens.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it "fills" 0.09p add the 0,0 to be sure it has 3 digits for money format. |
||
|
|
||
| //line 9 to 12= use substring to extrac from start form index 0 and string lenght taking 2 digits = reusl 3 | ||
|
|
||
| /// lines 14 to 16= const to the pence: the start indext for Substring will be 3-2= 1 | ||
| // true i got confused . padend make sure the pence part has 2 digits. if it dosen;t padend will add the 0 to it. if it has already 2 digits will stay the same | ||
|
|
||
| // line 18 = template literal with the results £3.99 | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good observation about the addition! One thing to refine: is
=doing the adding or is it doing something else? What's the difference between+and=in this line?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @jennethydyrova ,
the + is adding and the = is Assing the new valeu to the variable "count