-
-
Notifications
You must be signed in to change notification settings - Fork 391
London | 26-ITP-May | Damilola Odumosu | Sprint 1 | Coursework #1364
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
Open
d-odumosu
wants to merge
18
commits into
CodeYourFuture:main
Choose a base branch
from
d-odumosu:coursework/sprint-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
1f88977
answered question in 1-count.js
d-odumosu f2ed2f5
completed 2-initials.js and tested it with logging to the console
d-odumosu 302efee
completed 3-paths.js and tested it with logging to the console
d-odumosu 63ea100
completed 4-random.js and tested it with logging to the console
d-odumosu 7f35b33
Answered question in 0.js
d-odumosu e6d78a0
completed task in 1.js
d-odumosu 4ffd303
fixed the error in 2.js
d-odumosu 78253f1
fixed the error in 3.js and the code now runs
d-odumosu df2d214
fixed the variable naming in 4.js
d-odumosu d8e5852
answered all questions in 1-percentage-change.js
d-odumosu bae8454
answered all questions in 2-time-format.js
d-odumosu 20eeeea
answered all questions in 3-to-pounds.js
d-odumosu 03bde13
making changes per review
d-odumosu cc8849b
revised the code per review
d-odumosu c0aeb18
explanation of the use of _ and $ sign in variables
d-odumosu 58ca320
added: A comma is missing between the arguments
d-odumosu b6ac40f
renamed the variable from runtime to movieRuntime to be more descriptive
d-odumosu 8499cf6
added: changed the method indexof to lastindexof and removed the trai…
d-odumosu 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,5 @@ | ||
| 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?*/ | ||
|
|
||
| //Answer | ||
| //We will comment it out. |
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; | ||
| /* we cannot reassign a variable that was declared using the const keyword so we will change it to the let keyword | ||
| which allows us to reassign variables*/ | ||
|
|
||
| let age = 33; | ||
| age = age + 1; | ||
| console.log(age) |
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}`); | ||
|
|
||
|
|
||
| /* The variable is declared after it's been used and when we run the code we get this > ReferenceError: Cannot access | ||
| 'cityOfBirth' before initialization */ |
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,22 @@ | ||
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.slice(-4); | ||
| //const cardNumber = 4533787178994213; | ||
| //const last4Digits = cardNumber.slice(-4); | ||
|
|
||
|
|
||
| // to fix the code, we'll convert the number to a string because .slice does not work on number data type | ||
| let cardNumber = 4533787178994213; | ||
| cardNumber = cardNumber.toString() | ||
| let 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 | ||
|
|
||
| //Answer | ||
| // We are not logging to the console | ||
| // The slice method should be a positive number to represent the index position. | ||
|
|
||
| console.log(last4Digits) | ||
| //TypeError: cardNumber.slice is not a function |
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 = "8:53pm"; | ||
| const 24hourClockTime = "20:53"; | ||
| const twelveHourClockTime = "8:53pm"; | ||
| const twentyFouHourClockTime = "20:53"; | ||
|
|
||
|
|
||
| //when starting a variable name with a number we have to precede with either of _ or $ | ||
| // _ and $ have special meanings by convention | ||
|
|
||
| // A convention among professional programmers is to start a name with underscore for "private" variables. | ||
| // $ - is commonly associated with libraries and frameworks. |
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,36 @@ | ||
| const movieLength = 8784; // length of movie in seconds | ||
| // const movieLength = 8784; // length of movie in seconds | ||
| const movieLength = 879094; // 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 movieRuntime = `${totalHours}:${remainingMinutes}:${remainingSeconds}`; | ||
| console.log(movieRuntime); | ||
|
|
||
| // 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? | ||
| // 6 | ||
|
|
||
| // b) How many function calls are there? | ||
| // 1 | ||
|
|
||
| // c) Using documentation, explain what the expression movieLength % 60 represents | ||
| // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators | ||
| // % is the modulos operator, movieLength % 60 gives us the remainder, essentially we divide 60 by movieLenght and return the remainder | ||
|
|
||
| // d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
| /* we are subtracting remainingSeconds from movieLength, remainingSeconds is a variable that holds the result from totalMinutes % 60, | ||
| the expression in brackets will evaluate first and then the result divided by 60. | ||
| */ | ||
|
|
||
| // e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
|
|
||
| //movieRunTime | ||
| // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
| /* I have experimented with different values by changing the movieLength variable, and they all work, it works because we have | ||
| didn't hardcode our expressions and used variables. | ||
| */ | ||
|
|
||
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.
Could also add a prefix
formattedor a suffixStrto hint the variable stores a string.