-
-
Notifications
You must be signed in to change notification settings - Fork 398
London | 26-ITP-May | Gideon Defar | Sprint 1 | Coursework #1553
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
gideondefar
wants to merge
12
commits into
CodeYourFuture:main
Choose a base branch
from
gideondefar: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
12 commits
Select commit
Hold shift + click to select a range
3782ccb
docs: add multi-line comment explaining line 3 assignment
gideondefar 6c946bc
Add initials extraction logic
gideondefar 38663ff
Create dir and ext variables
gideondefar e2d0541
docs: explain random integer generation formula
gideondefar 0420930
Comment changing the declaration keyword from const to let will fix t…
gideondefar 6c20163
fix: resolve variable initialization order error
gideondefar 9f7fab4
fix: resolve mandatory errors and complete interpret exercises
gideondefar 1dc171d
Fix formatting of initials variable declaration
gideondefar 6ca968b
Extract file extension, lastDotIndex defined and clean up debug output
gideondefar fb2159a
Use consistent time format variable names
gideondefar 5879896
Remove commented-out code
gideondefar c3c4171
Write down the number of functions and the lines where they are called
gideondefar 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 |
|---|---|---|
|
|
@@ -2,3 +2,5 @@ | |
|
|
||
| const age = 33; | ||
| age = age + 1; | ||
|
|
||
| // unlike let, const variables cannot be reassigned once created. | ||
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,4 @@ | ||
| const 12HourClockTime = "8:53pm"; | ||
| const 24hourClockTime = "20:53"; | ||
| const clockTime12Hour = "8:53pm"; | ||
| const clockTime24Hour = "20:53"; | ||
| // Naming convention: In JavaScript, variable names cannot begin with a number. | ||
| // It would crash instantly with a syntax error: |
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 |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -20,3 +20,18 @@ console.log(`The percentage change is ${percentageChange}`); | |
| // d) Identify all the lines that are variable declarations | ||
|
|
||
| // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? | ||
|
|
||
| /* | ||
| a) There are four functions Line 4 & 5: | ||
| for eg, The expression Number(carPrice.replaceAll(",","")) is doing the following: | ||
|
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. Take another look at the function calls in this file. How many function calls are there in total? |
||
| 1. carPrice.replaceAll(",","") - This removes any commas from the carPrice string. | ||
| 2. Number(...) - This converts the resulting string into a number. | ||
| b) The uncaught syntax error is coming from line 5. The error occurs because there is a missing comma in the replaceAll method. | ||
| It should be carPrice.replaceAll(",", "") instead of carPrice.replaceAll("," ""). To fix this, add the missing comma. | ||
| c) The variable reassignment statements are on lines 4 and 5, where carPrice and priceAfterOneYear are being reassigned to their numeric values. | ||
| d) The variable declarations are on lines 1 and 2, where carPrice and priceAfterOneYear are declared using the let keyword. | ||
|
gideondefar marked this conversation as resolved.
|
||
|
|
||
| e) The purpose of the expression Number(carPrice.replaceAll(",", "")) is to convert a string representation of a number (with commas as thousands separators) into an actual number that can be used in mathematical operations. | ||
|
|
||
| Generally, the purpose of this expression is to convert a string representation of a number (with commas as thousands separators) into a actual number that can be used in mathematical operations. | ||
| */ | ||
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.
It looks like lastDotIndex has not been defined before it is used here.