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

WM4-Kavita-Patil-JavaScript-Core-1-Coursework-Week4 - #335

Closed
kavitappatil wants to merge 18 commits into
CodeYourFuture:masterfrom
kavitappatil:master
Closed

WM4-Kavita-Patil-JavaScript-Core-1-Coursework-Week4#335
kavitappatil wants to merge 18 commits into
CodeYourFuture:masterfrom
kavitappatil:master

Conversation

@kavitappatil

@kavitappatil kavitappatil commented Aug 3, 2022

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?


View rendered exercises/G-numbers/README.md
View rendered exercises/L-functions-nested/README.md


function getTotal(a, b) {
total = a ++ b;
total = a + b;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do you remember what we need to put at the start of the line when defining or creating a new variable?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I need to add var or let

total = a + b;

return "The total is total";
return `The total is ${total}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice use of string interpolation!

// Add comments to explain what this function does. You're meant to use Google!
function getRandomNumber() {

//returns a random number between 0 (included) and 1 (excluded) and multiple by 10:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do you know what kind of random number? Integer? Decimal? Negative or positive?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It always returns a number lower than 1.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could it return -100? Or 0.56?

Comment thread mandatory/4-tax.js

function calculateSalesTax() {}
function calculateSalesTax(price) {
var salesTax = price + price * .20;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This confused me to begin with as to why you were multiplying the price by 0.2. One of the reasons is that I have no idea what the significance of that number is. In the industry we'd refer to this as a "magic number". It's considered better to treat it as a named constant defined somewhere in your code. Some people/organisations will capitalize shared constants, something like:

const TAX_RATE = 0.2;

function calculateSalesTax(price) {
    let tax = price * TAX_RATE;
    return price + tax;
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

oh, ok thanks

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.

3 participants