Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.

London9-Elahe-Mortazavi-JavaScript-Core1-week1 - #430

Open
elahemortazavi wants to merge 9 commits into
CodeYourFuture:masterfrom
elahemortazavi:master
Open

London9-Elahe-Mortazavi-JavaScript-Core1-week1#430
elahemortazavi wants to merge 9 commits into
CodeYourFuture:masterfrom
elahemortazavi:master

Conversation

@elahemortazavi

Copy link
Copy Markdown

Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in HOW_TO_MARK.md in the root of this repository

Your Details

  • Your Name:
  • Your City:
  • Your Slack Name:

Homework Details

  • Module:
  • Week:

Notes

  • What did you find easy?

  • What did you find hard?

  • What do you still not understand?

  • Any other notes?

@SallyMcGrath SallyMcGrath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 Hi Elahe!

// Start by creating a variable `message`

var message = "anyone can help me with terminal?"
var messagetype = typeof message;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread mandatory/4-tax.js

function addTaxAndFormatCurrency() {}
function addTaxAndFormatCurrency(num) {
let final = ((num * 1.2).toFixed(2)).toString();

@SallyMcGrath SallyMcGrath Nov 30, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

@SallyMcGrath SallyMcGrath Nov 30, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, or even just

Suggested change
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;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌


function trimWord(word) {
return wordtrim();
return word.trim();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

total = a ++ b;
total = a + b;

return `The total is ${total}`;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@elahemortazavi

elahemortazavi commented Dec 1, 2022 via email

Copy link
Copy Markdown
Author

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants