generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 240
London | 25-ITP-September | Carlos Abreu | Sprint 1 | Coursework #862
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
carlosyabreu
wants to merge
28
commits into
CodeYourFuture:main
Choose a base branch
from
carlosyabreu: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 26 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
e1447e3
Increase by 1 the variable count
carlosyabreu f184b29
Assignment operator equal
carlosyabreu d88693e
2-initials.js first letters of the variables
carlosyabreu ad07e16
Directory and extension part of a file path
carlosyabreu fc159be
Explanation of 4-random.js file
carlosyabreu 92d1f33
Using comment to explain the information contain in the file, useful …
carlosyabreu 204a98d
Change keyword 'const' to 'let' to assign variable
carlosyabreu b9538b2
Variable must be declared first before it can be used
carlosyabreu 5b6a38f
Extracting the last 4 digits and display it
carlosyabreu 57e97e9
Change variable naming starting with letter instead of numbers
carlosyabreu 7e75245
Change function replaceAll arguments adding commas to separate its pa…
carlosyabreu a36e485
commit 2-time-format.js and 3-to-pounds.js
carlosyabreu 94b7128
Add alert and prompt function explanation
carlosyabreu 269ce23
Console.log and Console and property
carlosyabreu 7069bdc
Change 1-count.js file
carlosyabreu f5e4d38
Change 4-random.js file
carlosyabreu 9710e5f
Made change to the file
carlosyabreu ce03285
Use the short circut increment instead the traditonal one
carlosyabreu cedc8a3
Comment about variable hoisting
carlosyabreu dc0e00d
Converting a number to use slice function and display the last 4 digits
carlosyabreu 5726e67
Stay the same as before
carlosyabreu 044b702
Adjust the output adding the percentage symbol
carlosyabreu bec2478
Redesign the explanation
carlosyabreu 3adb077
Changed the comments and implementation making it more cleaner and sh…
carlosyabreu 2128a93
Explaining alert() and prompt() functions
carlosyabreu 85de39e
Explain the meaning of console.log and various console property and m…
carlosyabreu 0bbf7d8
Remote commented code making the branch clean
carlosyabreu f845550
Delete package-lock.json
carlosyabreu 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 was deleted.
Oops, something went wrong.
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,25 @@ | ||
| 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? | ||
|
|
||
| /** The lines that are just instructions or notes for humans and we don’t want the computer to execute them, we turn them into comments. | ||
|
|
||
| In JavaScript, there are two ways to write comments: | ||
|
|
||
| 1. Single-line comment | ||
|
|
||
| Use // at the start of a line. | ||
| Everything after // is ignored by the computer. | ||
|
|
||
| Example: | ||
|
|
||
| // This line explains what the code does | ||
| const num = 8; | ||
|
|
||
| 2. Multi-line comment | ||
|
|
||
| Use slash asterisk at beginning and asterisk slash at end to wrap several lines. | ||
|
|
||
| Example: | ||
| The comment wrapping this explanation | ||
| */ | ||
|
|
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; | ||
| age = age + 1; | ||
| // change keyword 'const' to 'let' | ||
| let age = 33; | ||
| 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,10 @@ | ||
| // 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}`); | ||
| // This is related to variable hoisting. | ||
| // const keywork is a block scope and unlike var it's not hoisted automatically. | ||
| // The easiest solution is to declare the variable before to use it | ||
|
|
||
| const cityOfBirth = "Bolton"; | ||
| console.log(`I was born in ${cityOfBirth}`); | ||
|
|
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,28 @@ | ||
| 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 | ||
|
|
||
| /** | ||
| *Prediction: Why won’t this code work? | ||
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.slice(-4); | ||
|
|
||
| The issue is that .slice() is a string method, but cardNumber here is a number — not a string. | ||
| So when the code runs, JavaScript will say something like: | ||
| TypeError: cardNumber.slice is not a function | ||
| That’s because .slice() function only works on strings or arrays — and numbers don’t have that method. | ||
|
|
||
| Fixing the problem: | ||
| To use .slice(), we need to convert the number into a string first: | ||
| */ | ||
|
|
||
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.toString().slice(-4); | ||
| console.log(last4Digits); // "4213" | ||
|
|
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,18 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| // const 12HourClockTime = "20:53"; | ||
| // const 24hourClockTime = "08:53"; | ||
|
|
||
| /** | ||
| * In javascript variable can't start with a number | ||
| * Can contain letters, digits (but not at the start), underscore _, and dollar signs $ | ||
| * | ||
| * const 12HourClockTime = "20:53"; will cause a SyntaxError because variable name can't begin with a number. | ||
| * | ||
| * To fix it need to chang the name to start with a letter. | ||
| */ | ||
|
|
||
| const twelveHourClockTime = "08:53"; | ||
| const twentyFourClockTime = "20:53"; | ||
|
|
||
| console.log(twelveHourClockTime); | ||
| console.log(twentyFourClockTime); | ||
|
|
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.
Can you please remove this commented code to keep the PR clean?
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.
Evening Jenny
Thanks for your reply.
I've followed your suggestion removing the comment and update PR making the branch clean.
Before reading your suggestion I didn't know that bit of code shouldn't be there.
Again thank you.
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.
package-lock.json is still there, can you please remove it as well?
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 Jenny
Sorry for delay.
I've deleted package-lock.json file.
I typed (git rm --cached package-lock.json) on terminal and committed and pushed to GitHub repo.
It's done.
And I created (.gitignore) file on local git repo and add (package-lock.json) on (.gitignore) so next next time I add, commit and push it doesn't be included onto GitHub upstream repo.
I think it's cleaned now.
Thank you