generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 315
London | 26-ITP-January | Karla Grajales | Sprint 1 | coursework/sprint-1 #910
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
Grajales-K
wants to merge
32
commits into
CodeYourFuture:main
Choose a base branch
from
Grajales-K: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
32 commits
Select commit
Hold shift + click to select a range
6c59bf1
exercise 0.js Done
Grajales-K 4ce90b9
fix: change const to let for age variable to allow reassignment
Grajales-K f1b26c1
fix: define cityOfBirth variable before usage in console.log
Grajales-K 89a42ab
fix: convert cardNumber to string before slicing last 4 digits
Grajales-K 8c269ba
fix: variable name to display the time
Grajales-K bd483c1
reassign value after declaration
Grajales-K 9be9270
feat: implement decimal extraction and rounding logic
Grajales-K 982f3b3
exercise: implement string indexing for initials
Grajales-K f7799bb
feat: extract root, filename and extension using slice and lastIndexOf
Grajales-K b9b2ba8
feat: generating number from min and max both inclusive
Grajales-K 850edaa
doc: documented the process to convert string in number to make math …
Grajales-K 1795109
docs: testing and documentation about behavior of calling a prompt an…
Grajales-K 924741c
docs: testing and documentation on how works console log and assert.
Grajales-K 188692d
docs: adding title to better understanding
Grajales-K 0870089
docs: documentation on how works the call in each functions and using…
Grajales-K aaaaf02
docs: documentation about how works math calculations using the modul…
Grajales-K f00b454
branch was Out of sync from main
Grajales-K 2bfaf27
fix: the sync from main, added method charArt()
Grajales-K 9a8bc46
fix: resolving conflict with branches
Grajales-K d1fffc7
refactor: add more comments to my console.log()
Grajales-K 5ddfa8d
Merge branch 'CodeYourFuture:main' into coursework/sprint-1
Grajales-K 9127036
Merge branch 'CodeYourFuture:main' into coursework/sprint-1
Grajales-K 29f3107
Merge branch 'main' into coursework/sprint-1
Grajales-K cfad983
fix: update console log message for clarity
Grajales-K f044737
feat: solve math exercise and add custom rounding function
Grajales-K 5bcbfee
fix: moved the const num down the comments fot better readability
Grajales-K 1f97c40
fix: resolving the floating point error to display exactly 4 decimals
Grajales-K e47833b
docs: provide detailed breakdown of the random number generation logic
Grajales-K bdd3224
fix: update the number of function calls and improve readability in t…
Grajales-K 51a63b1
docs: update README with prompt return values and console logs
Grajales-K c2a4e1f
fix: string
Grajales-K a50390f
Remove files previously deleted in remote
Grajales-K 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,31 @@ | ||
| // 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 | ||
|
|
||
| const minimum = 1; | ||
| const maximum = 100; | ||
|
|
||
| const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; | ||
| //this line will generate a random number between minimum and maximum (inclusive) | ||
| // and math.floor will remove decimal part | ||
|
|
||
| Math.floor() //removes decimal part and returns whole number | ||
| Math.random() //needs to values between minimum and maximum to generate a random number | ||
|
|
||
| console.log(maximum - minimum + 1 ) + minimum; // this is same as 100 - 1 + 1 = 100 | ||
| console.log(`The random number is ${num}`); | ||
|
|
||
|
|
||
| // breaking down the expressions | ||
| // We subtract the minimum from the maximum to find the absolute range (the distance) | ||
| // between the two numbers. This tells Math.random() how many possible values it needs | ||
| // to generate. We add it back at the end to shift the starting point from 0 to our desired minimum. | ||
|
|
||
|
|
||
| // 1. Range = (100 - 1 + 1) -> We have 100 possible integers. | ||
| // 2. Scaling = Math.random() * 100 -> Gives a decimal between 0 and 99.99. | ||
| // 3. Integer = Math.floor(0 to 99.99) -> Gives a whole number between 0 and 99. | ||
| // 4. Offset = (0 to 99) + 1 -> Shifts the result to be between 1 and 100. | ||
|
|
||
|
|
||
| // 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 |
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,7 @@ | ||
| 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 | ||
| //to write comments in JavaScript, we use two forward slashes like this so, for this exercise, | ||
| // we can comment out the two lines above to prevent them from being executed. |
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,7 @@ | ||
| // trying to create an age variable and then reassign the value by 1 | ||
|
|
||
| const age = 33; | ||
| age = age + 1; | ||
| let age = 33; | ||
| age += 1; | ||
| console.log(age); | ||
|
|
||
| // We need to use 'let' to reassign a variable; 'const' does not allow reassignment. |
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}`); | ||
|
|
||
| // explanation: the error was that the variable cityOfBirth was not defined before it was used in the console.log statement. | ||
|
|
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,20 @@ | ||
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.slice(-4); | ||
| const numberString = cardNumber.toString(); | ||
| const last4Digits = numberString.slice(-4); | ||
| const num = Number(last4Digits); | ||
|
|
||
| console.log(num); | ||
Grajales-K marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // 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 | ||
|
|
||
|
|
||
|
|
||
| // explanation: to see the numbers correctly we need to convert the cardNumber to a string | ||
| // first before slicing the last 4 digits. The original code was trying to use slice | ||
| // a number, which is not valid. By converting it to a string first, | ||
| // we can then slice the last 4 characters correctly. Then we convert it back to a number. | ||
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,11 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
|
|
||
| // explanation: the first lines will throw an error because js detect a number instead of a variable name, | ||
| // so we move the number to the end and now it works fine. | ||
| // const 24hourClockTime = "08:53; | ||
| // const 12HourClockTime = "20:53"; | ||
|
|
||
|
|
||
| const clock12h = "20:53"; | ||
| const clock24h = "08:53"; | ||
| console.log(clock12h); | ||
| console.log(clock24h); |
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
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.
Uh oh!
There was an error while loading. Please reload this page.