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

NW Class 4 - Maha Malik - JS Core 1 - Week 1 - #110

Closed
maham511 wants to merge 9 commits into
CodeYourFuture:masterfrom
maham511:master
Closed

NW Class 4 - Maha Malik - JS Core 1 - Week 1#110
maham511 wants to merge 9 commits into
CodeYourFuture:masterfrom
maham511:master

Conversation

@maham511

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: Maha Malik
  • Your City: NW4
  • Your Slack Name: Maha Malik

Homework Details

  • Module: JS Core 1
  • Week: 1

Notes

  • What did you find easy?
    'Exercises' tasks were fairly easy to understand, but got harder as the tasks progressed. Running tests was very helpful in debugging once I got used to the Jest interface/layout.

  • What did you find hard?
    Struggle with knowing how and when to store functions into variables, and using variables within functions, it'll probably get clearer with practice. Nesting functions is a bit overwhelming, also knowing where to put parameters in nested functions.

  • What do you still not understand?
    Same as above

  • Any other notes?

@@ -1,17 +1,19 @@
// Add comments to explain what this function does. You're meant to use Google!
//My Comment - This function gives a random number by using math.random() and multiplying the value 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.

Can you explain the range of the random numbers that will be returned? What range does Math.random() return, and so what will your method return?

Comment thread mandatory/4-tax.js

function calculateSalesTax() {}
function calculateSalesTax(num) {
return num *1.2; //Adds 20% to number and gives total price including tax

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You could also declare 1.2 as a variable called priceWithTax or something similar, or even declare 0.2 as a variable call tax, and then multiply by the price and then add to the price. This would would make it easier to understand what your code is doing. However, your solution has the advantage of being concise. Both approaches work, so it's a matter of taste.

Comment thread mandatory/4-tax.js

//CAN ALSO WRITE THIS WAY:
// function addTaxAndFormatCurrency(num) {
// var totalPrice= `£${calculateSalesTax(num).toFixed(2)}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yes, as discussed in the previous comment, the first is more concise, but sometimes breaking your code down into stages and declaring variables with good names helps to make your code more understandable. It's up to you which you prefer.

function createGreeting(name) {
var greeting = `Helloooo ${name}`;
return greeting.toUpperCase();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

the idea of this exercise was to have 2 separate functions, one that returns the name in uppercase and another that returns the greeting by calling the first function to get the name

function concatenate(firstWord, secondWord, thirdWord) {
// Write the body of this function to concatenate three words together.
// Look at the test case below to understand what this function is expected to return.
return `${firstWord} ${secondWord} ${thirdWord}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

can you do this using the .concat() method?

@lannem lannem left a comment

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 work Maha :)

@github-actions

Copy link
Copy Markdown

Your coursework submission has been closed because nobody has interacted with it in six weeks. You are welcome to re-open it to get more feedback.

@github-actions github-actions Bot added the Stale label Aug 18, 2021
@github-actions github-actions Bot closed this Aug 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants