London9-Elahe-Mortazavi-JavaScript-Core1-week1 - #430
Conversation
SallyMcGrath
left a comment
There was a problem hiding this comment.
Lovely to read this, Elahe! Thanks so much for your hard work here. Serious props for trying the extras and stretches -- I know you get a ton of assignments.
I've dropped a few notes. Look through the solutions yourself and have a think about some of the things I've said. Thanks again! 🎉
| console.log(greeting); | ||
| console.log(greeting); | ||
| console.log(greeting); | ||
|
|
| // Start by creating a variable `message` | ||
|
|
||
| var message = "anyone can help me with terminal?" | ||
| var messagetype = typeof message; |
There was a problem hiding this comment.
| var messagetype = typeof message; | |
| console.log(typeof message) |
You can do this query right inside the console.log
|
|
||
| var greetingStart = "Hello, my name is "; | ||
| var name = "elahe"; | ||
| var message = greetingStart + name; |
There was a problem hiding this comment.
Great! An even easier way to do this would be with template literals. Look in the example solution to find out what these are.
| var nameLength = name.length; | ||
| console.log(nameLength); | ||
|
|
||
| let newString = (`my name is ${name} which includes ${nameLength} characters`); |
There was a problem hiding this comment.
Oh here you are using template literals! Hurray. Let's prefer this way of putting code inside strings in general.
|
|
||
|
|
||
| console.log(newString.trim()); | ||
| // why trim is not working here? |
There was a problem hiding this comment.
It's because newString doesn't have whitespace either side of it. The extra whitespace is now inside the string. That is to say, when the variable name is placed inside the newString, where is the whitespace going to end up?
|
|
||
| function addTaxAndFormatCurrency() {} | ||
| function addTaxAndFormatCurrency(num) { | ||
| let final = ((num * 1.2).toFixed(2)).toString(); |
There was a problem hiding this comment.
I think this task is hinting for you to reuse the function you just wrote. Look up at calculateSalesTax. How can you use that function again here? How would using the function make this code clearer?
I also think this variable name could be clearer. Why is naming variables clearly a great way to improve our code?
| a * b * c; | ||
| return; | ||
| let result = a * b * c; | ||
| return result; |
There was a problem hiding this comment.
Yes, or even just
| return result; | |
| return a * b * c |
In this case we get no extra clarity from storing the expression in this result variable. Clarity is the goal!
|
|
||
| function getStringLength(word) { | ||
| return "word".length(); | ||
| return word.length; |
|
|
||
| function trimWord(word) { | ||
| return wordtrim(); | ||
| return word.trim(); |
| total = a ++ b; | ||
| total = a + b; | ||
|
|
||
| return `The total is ${total}`; |
|
Dear Sally
A huge thanks regarding your comment on my PR. I appreciate the way you
write them in really respectful and encouraging way, which convinced me to
read it word by word.
Best regards
Ellie
…On Wed, Nov 30, 2022 at 7:38 PM Sally McGrath ***@***.***> wrote:
***@***.**** commented on this pull request.
Lovely to read this, Elahe! Thanks so much for your hard work here.
Serious props for trying the extras and stretches -- I know you get a ton
of assignments.
I've dropped a few notes. Look through the solutions yourself and have a
think about some of the things I've said. Thanks again! 🎉
------------------------------
In exercises/C-variables/exercise.js
<#430 (comment)>
:
> console.log(greeting);
+console.log(greeting);
+
👋 Hi Elahe!
------------------------------
In exercises/D-strings/exercise.js
<#430 (comment)>
:
> @@ -1,3 +1,4 @@
// Start by creating a variable `message`
-
+var message = "anyone can help me with terminal?"
+var messagetype = typeof message;
⬇️ Suggested change
-var messagetype = typeof message;
+console.log(typeof message)
You can do this query right inside the console.log
------------------------------
In exercises/E-strings-concatenation/exercise.js
<#430 (comment)>
:
> @@ -1,3 +1,5 @@
// Start by creating a variable `message`
-
+var greetingStart = "Hello, my name is ";
+var name = "elahe";
+var message = greetingStart + name;
Great! An even easier way to do this would be with template literals. Look
in the example solution to find out what these are.
------------------------------
In exercises/F-strings-methods/exercise2.js
<#430 (comment)>
:
> @@ -1,3 +1,14 @@
-const name = " Daniel ";
+var name = " Elahe";
+var nameLength = name.length;
+console.log(nameLength);
+
+let newString = (`my name is ${name} which includes ${nameLength} characters`);
Oh here you are using template literals! Hurray. Let's prefer this way of
putting code inside strings in general.
------------------------------
In exercises/F-strings-methods/exercise2.js
<#430 (comment)>
:
> @@ -1,3 +1,14 @@
-const name = " Daniel ";
+var name = " Elahe";
+var nameLength = name.length;
+console.log(nameLength);
+
+let newString = (`my name is ${name} which includes ${nameLength} characters`);
+console.log(newString);
+
+
+console.log(newString.trim());
+// why trim is not working here?
It's because newString doesn't have whitespace either side of it. The
extra whitespace is now inside the string. That is to say, when the
variable name is placed inside the newString, where is the whitespace
going to end up?
------------------------------
In exercises/G-numbers/exercise.js
<#430 (comment)>
:
> @@ -1 +1,4 @@
// Start by creating a variables `numberOfStudents` and `numberOfMentors`
+let numberOfStudents = 70;
+let numberOfTeachers = 20;
+console.log(numberOfStudents+numberOfTeachers);
👍
------------------------------
In mandatory/1-syntax-errors.js
<#430 (comment)>
:
> return a + b + c;
+
+}
+
+
+
+function introduceMe(name, age){
+
+ return "Hello, my name is " + name + " and I am " + age + " years old";
Fab!
------------------------------
In mandatory/3-function-output.js
<#430 (comment)>
:
>
// Add comments to explain what this function does. You're meant to use Google!
function combine2Words(word1, word2) {
return word1.concat(word2);
-}
+}
+// CONCAT: to mix arrays together we can use concat. the other way is spread operator.
I understand what you are saying here and this answer is correct. 🥇
A clearer way to say it might be to say link or connect instead of mix.
Mix implies the values might be "mixed up" / disordered in the new array,
but they retain their original sequence order.
CONCAT: to *link* arrays together we can use concat. the other way is
spread operator.
------------------------------
In mandatory/4-tax.js
<#430 (comment)>
:
> @@ -17,7 +20,16 @@ function calculateSalesTax() {}
Remember that the prices must include the sales tax (hint: you already wrote a function for this!)
*/
-function addTaxAndFormatCurrency() {}
+function addTaxAndFormatCurrency(num) {
+ let final = ((num * 1.2).toFixed(2)).toString();
⬇️ Suggested change
- let final = ((num * 1.2).toFixed(2)).toString();
+ let final = ((num * 1.2).toFixed(2)).toString();
I think this task is hinting for you to reuse the function you just wrote.
Look up at calculateSalesTax. How can you use that function again here? How
would using the function make this code clearer?
I also think this variable name could be clearer. Why is naming variables
clearly a great way to improve our code?
------------------------------
In mandatory/2-logic-error.js
<#430 (comment)>
:
> function multiply(a, b, c) {
- a * b * c;
- return;
+ let result = a * b * c;
+ return result;
Yes, or even just
⬇️ Suggested change
- return result;
+ return a * b * c
------------------------------
In mandatory/2-logic-error.js
<#430 (comment)>
:
> function getStringLength(word) {
- return "word".length();
+ return word.length;
🙌
------------------------------
In mandatory/2-logic-error.js
<#430 (comment)>
:
> @@ -1,18 +1,26 @@
// The syntax for this function is valid but it has an error, find it and fix it.
function trimWord(word) {
- return wordtrim();
+ return word.trim();
👍
------------------------------
In mandatory/1-syntax-errors.js
<#430 (comment)>
:
>
function getTotal(a, b) {
- total = a ++ b;
+ total = a + b;
+
+ return `The total is ${total}`;
👍
—
Reply to this email directly, view it on GitHub
<#430 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AZKIJWKL3QJQ533BS34EIWLWK6UK5ANCNFSM6AAAAAASI5XKYA>
.
You are receiving this because you authored the thread.Message ID:
<CodeYourFuture/JavaScript-Core-1-Coursework-Week1/pull/430/review/1199240736
@github.com>
|
Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in
HOW_TO_MARK.mdin the root of this repositoryYour Details
Homework Details
Notes
What did you find easy?
What did you find hard?
What do you still not understand?
Any other notes?