-
-
Notifications
You must be signed in to change notification settings - Fork 382
London | 26-ITP-Jan | Kris Oldrini | Sprint 1 | Coursework #988
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
Closed
Closed
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a3277b1
complete exercise 1-count
XiaoQuark db4e4ac
complete exercise 2-initials
XiaoQuark 0b7d189
complete exercise 3-paths
XiaoQuark 92282ff
refactor exercise 3-paths
XiaoQuark 1c71d92
complete exercise 4-random
XiaoQuark 83a0987
complete mandatory-errors/0
XiaoQuark b952753
complete mandatory-errors/1
XiaoQuark 0d9eb1d
add explanation to mandatory-errors/0
XiaoQuark 16c3259
add explanation to mandatory-errors/1
XiaoQuark 5a68f2c
complete exercise mandatory-errors/2
XiaoQuark aad1abe
complete mandatory-errors/3
XiaoQuark d97b50e
complete exercise mandatory-errors/4
XiaoQuark 2193c03
complete 1-percentage-change
XiaoQuark 82c02c0
complete 2-time-format
XiaoQuark 974ed0e
complete 3-to-pounds
XiaoQuark 31a1166
refactor 3-paths to fix encoding error
XiaoQuark 5480a21
complete 4-stretch-explore
XiaoQuark b574e15
fix logic for selecting dir part
XiaoQuark 9bbcc82
refactor: remove the console.log()
XiaoQuark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,6 @@ | ||
| 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? | ||
|
|
||
| // Explanation | ||
| // The computer will try to run anything that is not a comment. To make comments we can add // at the beginning of a line (ctrl + /) | ||
| // for multiple line comments we use /* text */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,8 @@ | ||
| // trying to create an age variable and then reassign the value by 1 | ||
|
|
||
| const age = 33; | ||
| let age = 33; | ||
| age = age + 1; | ||
|
|
||
| // const are variables which value cannot change | ||
| // let is a variable which value can be updated | ||
| // to fix the error I modified the variable declaration and used let instead of const |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| // 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}`); | ||
|
|
||
| // ReferenceError: Cannot access 'cityOfBirth' before initialization | ||
| // This error appears because the variable cityOfBirth is created after the console.log, so the computer cannot access it. | ||
| // To fix the error I just moved the console.log below the variable declaration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,12 @@ | ||
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.slice(-4); | ||
| const last4Digits = String(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 | ||
|
|
||
| // slice() is a String method, but cardNumber is a data of type Number, so we cannot use String methods on it. | ||
| // A simple solution is to transform cardNumber into a string using the string constructor String() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 clockTime12Hour = "08:53"; | ||
| const clockTime24Hour = "20:53"; | ||
|
|
||
| // I see two errors here: | ||
| // 1 - In Javascript, variable names cannot start with numbers. | ||
| // 2 - The variable names are both descriptive, which is correct, but their values seem to have been swapped with each other: the 24h clock should be 20:53 and the 12h clock 08:53 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,31 @@ | ||
| const movieLength = 8784; // length of movie in seconds | ||
| const movieLength = 98686; // length of movie in seconds | ||
|
|
||
| const remainingSeconds = movieLength % 60; | ||
| const totalMinutes = (movieLength - remainingSeconds) / 60; | ||
|
|
||
| const remainingMinutes = totalMinutes % 60; | ||
| const totalHours = (totalMinutes - remainingMinutes) / 60; | ||
|
|
||
| const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`; | ||
| console.log(result); | ||
| const formattedMovieLength = `${totalHours}:${remainingMinutes}:${remainingSeconds}`; | ||
| console.log(formattedMovieLength); | ||
|
|
||
| // 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? | ||
| // There are 6 variable declarations, on lines 1, 3, 4, 6, 7 and 9 | ||
|
|
||
| // b) How many function calls are there? | ||
| // There is only 1 function call on line 10 (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 | ||
| // The % is called modulo operator. This operator divides a number by a chosen value (in this case 60) and returns the leftover amount: i.e.: 130 % 60 = 10 | ||
|
|
||
| // d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
| // remainingSeconds is the leftover of movieLength divided by 60, meaning it's a number of seconds smaller than 1 minute. In line 4, these seconds are first subtracted from the total length of the movie, leaving a number of seconds that, when divided by 60, will result in an integer number, giving us the number of full minutes in the movie (totalMinutes) | ||
|
|
||
| // e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
| // result is a string with the movie length in H:M:S format. A possible better name could be formattedMovieLength | ||
|
|
||
| // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
| // The code technically works. It always return the movie length with a H:M:S format, but with room for improvement. In cases where the number of seconds or minutes are less than 10, they are displayed as only 1 digit. But conventional time formatting would require 2 digits. For example, a time of 2 hours, 7 minutes and 3 seconds, should be displayed as 03:02:07, but the code would print 2:7:3, making difficult to identify the result as a length of time. To improve the code, we could add logic that would account for cases in which the hour, minutes or seconds are less than 10 by adding a 0 before them. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Look at this properly console.log the result, I does not print out the
dirpart of the filePath variableThere 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 Emmanuel, thank you for your comment.
I see I'm missing the root in my
dir, so I will get on to changing that. May I ask you about the last/just before the base? Would that also be part of thedir?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.
Sorry @XiaoQuark can help with the questions, can only review, I will advice that you really reveiw the questions and what you need to do, so far, you are honestly doing a good job.
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.
No worries, I think I got it right this time.
The last
/should be considered a separator and not part of thediritself.