-
-
Notifications
You must be signed in to change notification settings - Fork 42
Js/week 1/davinder #17
base: master
Are you sure you want to change the base?
Conversation
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.
Good job on this Davinder. Well done for taking on the extra exercises too. I'd have another go at fixing the word trim function in the second exercise. One minor point - it helps improve the legibility of the code by adding spaces between operators, but don't worry too much about this :)
@@ -30,6 +30,6 @@ function test(test_name, expr) { | |||
console.log(`${test_name}: ${status}`) | |||
} | |||
|
|||
test("fixed trimWord function", trimWord(" CodeYourFuture ") === "CodeYourFuture") | |||
test("fixed trimWord function", trimWord("CodeYourFuture") === "CodeYourFuture") |
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.
The test isn't supposed to be modified, try and get the trimWord
function to do the right thing and trim the provided string.
function calculateSalesTax() {} | ||
function calculateSalesTax(price) | ||
{ | ||
var tax=1.2*price; |
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.
Just to make the code easier to read, add a space before you use operators (such as =
and *
).
function formatCurrency() {} | ||
function formatCurrency(number) | ||
{ | ||
tax=calculateSalesTax(number); |
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.
This is missing a var
before tax
.
@@ -5,7 +5,10 @@ | |||
Write a function that converts a price to USD (exchange rate is 1.4 $ to £) | |||
*/ | |||
|
|||
function convertToUSD() {} | |||
function convertToUSD(pound_price) |
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.
In JavaScript, the preferred style to use when naming variables is camel case, so here you would have poundPrice
.
} | ||
|
||
const startingValue = 2 | ||
|
||
// Why can this code be seen as bad practice? Comment your answer. | ||
let badCode = | ||
|
||
let badCode = "Bad practice is when we do not generalise the code "; |
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.
Generalising the code is usually a good thing to do but this is not what was meant in the exercise.
- Using the variable startingValue as input, perform the following operations using your functions all
on one line (assign the result to the variable badCode):
- add 10 to startingValue
- multiply the result by 2
- format it
This was asking what you thought about all the code to carry out these operations being on one line.
/* BETTER PRACTICE */ | ||
|
||
let goodCode = | ||
let goodCode = "A function is useful when it can be applied to many domains, in short we should to generalise it as much as we can"; |
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.
And here, it was seeing what the code above would look like on multiple lines, so it would read much better (which is definitely good practice that is encouraged here).
Good Afternoon Ben
Thank-you so much for reviewing my homework and giving me feedback, sorry
for the late reply. I just saw your email because it was moved to junk mail
for some reason. I will pay attention to it and will try to improve my
coding skills,
Yours sincerely
Davinder Singh
…On Tue, Jul 7, 2020 at 9:07 PM Ben Paddock ***@***.***> wrote:
***@***.**** approved this pull request.
Good job on this Davinder. Well done for taking on the extra exercises
too. I'd have another go at fixing the word trim function in the second
exercise. One minor point - it helps improve the legibility of the code by
adding spaces between operators, but don't worry too much about this :)
------------------------------
In week-1/2-mandatory/2-logic-error.js
<#17 (comment)>
:
> @@ -30,6 +30,6 @@ function test(test_name, expr) {
console.log(`${test_name}: ${status}`)
}
-test("fixed trimWord function", trimWord(" CodeYourFuture ") === "CodeYourFuture")
+test("fixed trimWord function", trimWord("CodeYourFuture") === "CodeYourFuture")
The test isn't supposed to be modified, try and get the trimWord function
to do the right thing and trim the provided string.
------------------------------
In week-1/2-mandatory/4-tax.js
<#17 (comment)>
:
> @@ -5,7 +5,12 @@
Sales tax is 20% of the price of the product
*/
-function calculateSalesTax() {}
+function calculateSalesTax(price)
+{
+ var tax=1.2*price;
Just to make the code easier to read, add a space before you use operators
(such as = and *).
------------------------------
In week-1/2-mandatory/4-tax.js
<#17 (comment)>
:
> @@ -17,7 +22,13 @@ function calculateSalesTax() {}
Remember that the prices must include the sales tax (hint: you already wrote a function for this!)
*/
-function formatCurrency() {}
+function formatCurrency(number)
+{
+ tax=calculateSalesTax(number);
This is missing a var before tax.
------------------------------
In week-1/3-extra/1-currency-conversion.js
<#17 (comment)>
:
> @@ -5,7 +5,10 @@
Write a function that converts a price to USD (exchange rate is 1.4 $ to £)
*/
-function convertToUSD() {}
+function convertToUSD(pound_price)
In JavaScript, the preferred style to use when naming variables is camel
case, so here you would have poundPrice.
------------------------------
In week-1/3-extra/2-piping.js
<#17 (comment)>
:
> }
const startingValue = 2
// Why can this code be seen as bad practice? Comment your answer.
-let badCode =
-
+let badCode = "Bad practice is when we do not generalise the code ";
Generalising the code is usually a good thing to do but this is not what
was meant in the exercise.
1. Using the variable startingValue as input, perform the following
operations using your functions all
on one line (assign the result to the variable badCode):
- add 10 to startingValue
- multiply the result by 2
- format it
This was asking what you thought about all the code to carry out these
operations being on one line.
------------------------------
In week-1/3-extra/2-piping.js
<#17 (comment)>
:
> /* BETTER PRACTICE */
-let goodCode =
+let goodCode = "A function is useful when it can be applied to many domains, in short we should to generalise it as much as we can";
And here, it was seeing what the code above would look like on multiple
lines, so it would read much better (which is definitely good practice that
is encouraged here).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#17 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APIBOIEWY4HEEIFF4WAT6E3R2N56PANCNFSM4OCVO5MA>
.
|
Your Details
Your Name: Davinder Singh
Your City: Birmingham
Your Slack Name: Davinder Singh
Homework Details
Module: Javascript
Week: 1