-
-
Notifications
You must be signed in to change notification settings - Fork 224
London|26-ITP-January|Alexandru Pocovnicu|Sprint 1|Feature/destructuring #411
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
alexandru-pocovnicu
wants to merge
8
commits into
CodeYourFuture:main
Choose a base branch
from
alexandru-pocovnicu:feature/destructuring
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
8 commits
Select commit
Hold shift + click to select a range
05b8512
updted syntax to destructure the object
alexandru-pocovnicu cbecb77
updated parameter to destructure the object argument
alexandru-pocovnicu cdbcc52
extracted the names of those who belong to the house of Gryffindor
alexandru-pocovnicu 28ba478
display the names of teachers with pets
alexandru-pocovnicu ec7c3bd
add loop to calculate and display total prices for order items
alexandru-pocovnicu 0d0f0e3
fix: correct function call to use the proper variable name
alexandru-pocovnicu 0dcbfed
refactor: change order declaration to const and improve variable scoping
alexandru-pocovnicu 7cd8394
calculate and display total bill correctly
alexandru-pocovnicu 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,10 +3,12 @@ const personOne = { | |
| age: 34, | ||
| favouriteFood: "Spinach", | ||
| }; | ||
| let {name,age,favouriteFood}=personOne; | ||
|
|
||
|
|
||
| // Update the parameter to this function to make it work. | ||
| // Don't change anything else. | ||
| function introduceYourself(___________________________) { | ||
| function introduceYourself({name,age,favouriteFood}) { | ||
|
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. Adding some white space between the brackets can make the code more readable. How can you ensure consistent formatting across the code base? |
||
| console.log( | ||
| `Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.` | ||
| ); | ||
|
|
||
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,8 +1,28 @@ | ||
| let order = [ | ||
| { itemName: "Hot cakes", quantity: 1, unitPricePence: 232 }, | ||
| const order = [ | ||
| { itemName: "Hot Cakes", quantity: 1, unitPricePence: 232 }, | ||
| { itemName: "Apple Pie", quantity: 2, unitPricePence: 139 }, | ||
| { itemName: "Egg McMuffin", quantity: 1, unitPricePence: 280 }, | ||
| { itemName: "Sausage McMuffin", quantity: 1, unitPricePence: 300 }, | ||
| { itemName: "Hot Coffee", quantity: 2, unitPricePence: 100 }, | ||
| { itemName: "Hash Brown", quantity: 4, unitPricePence: 40 }, | ||
| ]; | ||
|
|
||
| console.log("QTY ITEM TOTAL"); | ||
| const allPrices = []; | ||
| let totalBill; | ||
| for (const item of order) { | ||
| const { itemName, quantity, unitPricePence } = item; | ||
| const totalPence = quantity * unitPricePence; | ||
| const totalPenceString = totalPence.toString(); | ||
| const pence = totalPenceString.slice(-2); | ||
| const pounds = totalPenceString.slice(0, -2); | ||
| const total = `${pounds}.${pence}`; | ||
|
|
||
| allPrices.push(totalPence); | ||
| const totalBillString = String(allPrices.reduce((acc, curr) => acc + curr)); | ||
| totalBill = `${totalBillString.slice(0, -2)}.${totalBillString.slice(-2)}`; | ||
| console.log(quantity.toString().padEnd(7), itemName.padEnd(19), total); | ||
| } | ||
| console.log(); | ||
|
|
||
| console.log(`Total: ${totalBill}`); |
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.
What is the reason for this line?