-
-
Notifications
You must be signed in to change notification settings - Fork 386
Glasgow | Jan-26 | Elisabeth Matulian | Sprint 1 | Coursework #936
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
Changes from 16 commits
de40d9d
697d88c
519042c
4b1a9d9
4d7676a
c007b11
de87e88
98976cf
2c37761
984ab50
04ae366
22e28cd
6f38725
2949452
3ad69fa
dcaad30
f66258c
8962e17
e88aa97
88000ae
4013faf
6613221
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,2 +1,2 @@ | ||
| 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? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| // trying to create an age variable and then reassign the value by 1 | ||
|
|
||
| const age = 33; | ||
| let age = 33; | ||
| age = age + 1; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| // 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}`); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| const ClockTime12Hour = "20:53"; | ||
| const ClockTime24Hour = "08:53"; | ||
|
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. Very good variable naming convention. A bit of explanation with comments as to why you got an error and how you figured out the solution would help better practice.
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. Comment added |
||
| 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,17 @@ 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 | ||
| // a) Lines 4,5,10 | ||
|
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 need to include a number of function calls in there after looking into each line properly.
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. answer added for the first question. I need to be more attentive%)
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. Thank you for checking my coursework and for your detailed feedback. I have updated it. Could you please take another look when you have a moment? |
||
|
|
||
| // 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? | ||
| // b) The error on the 5th line. Absence of , between arguments. | ||
|
|
||
| // c) Identify all the lines that are variable reassignment statements | ||
| // c) Lines 4,5 | ||
|
|
||
| // d) Identify all the lines that are variable declarations | ||
| // d) Lines 1,2,7,8 | ||
|
|
||
| // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? | ||
| // e) This expression is removing the sign , from the carPrice variable then transforming the value from string to integer. | ||
| // The purpose of this expression is to convert the value of the variable into a form that is accessible for arithmetic calculations. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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? | ||
| // a) 6 | ||
|
|
||
| // b) How many function calls are there? | ||
| // b) 1 | ||
|
|
||
| // c) Using documentation, explain what the expression movieLength % 60 represents | ||
| // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators | ||
| // c) This expression shows the remaining part after dividing one number by another. | ||
| // This way we find out how many seconds are not enough to make up a full minute. | ||
|
|
||
| // d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
| // d) This way, we find out how many full minutes the film lasts. | ||
|
|
||
| // e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
| // e) This variable stores information about the exact length of the film (hours:minutes:seconds). I would call it “hoursMinutesSeconds” | ||
|
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. This part is really subjective, but if you could go with a better variable name based on the context provided from the existing variable names, that would be better.
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. I updated the name of the variable |
||
|
|
||
| // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
| // f) I tried several values where the length of the film is 0 or only a few minutes/seconds, etc. The code works in all the cases I tried and returns 0 as the result if the film, for example, is less than an hour long. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,8 +11,11 @@ In the Chrome console, | |
| invoke the function `alert` with an input string of `"Hello world!"`; | ||
|
|
||
| What effect does calling the `alert` function have? | ||
| Answer: A window pops up in the browser with the text “Hello world!” | ||
|
|
||
| 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? | ||
| Answer: A window pops up in the browser with a text input field | ||
| What is the return value of `prompt`? | ||
| Answer: undefined | ||
|
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 can recheck if the return type is actually what you say it is. If you input your name in the prompt, you should get the datatype for your name returned.
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. updated with the correct answer |
||
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.
Can you take a look at the output this line gives you and check if it aligns exactly with the full dir path as indicated in the task?
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.
I removed the second parameter from lastIndexOf and reused the existing lastSlashIndex variable