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

WM4-Azin Yadegari-JavaScript-Core-1-Coursework-Week1#326

Closed
AzinYad wants to merge 4 commits into
CodeYourFuture:masterfrom
AzinYad:master
Closed

WM4-Azin Yadegari-JavaScript-Core-1-Coursework-Week1#326
AzinYad wants to merge 4 commits into
CodeYourFuture:masterfrom
AzinYad:master

Conversation

@AzinYad
Copy link
Copy Markdown

@AzinYad AzinYad commented Aug 2, 2022

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: Azin
  • Your City: Birmingham
  • Your Slack Name: AzinYad

Homework Details

  • Module: JavaScript-Core-1-Coursework
  • Week1

Notes

  • What did you find easy?

  • What did you find hard?

  • What do you still not understand?

  • Any other notes?


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

// Declare your function here

function createLongGreeting(name,age){
return `Hello, my name is ${name} and I'm ${age} years old`;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good use of the interpolation.

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.

Thanks Irina

@AzinYad
Copy link
Copy Markdown
Author

AzinYad commented Aug 4, 2022

@jdbevan sorry Jon I couldn't find a proper way to add you as a reviewer for this week assignment ,that I created a pull request few days a go

Copy link
Copy Markdown

@simeonbikov simeonbikov left a comment

Choose a reason for hiding this comment

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

Well done!

@@ -1,3 +1,6 @@
const name = " Daniel ";

const message=`My name is Daniel and my name is 6 characters long`;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your code should be more versatile if you use variable instead of 'Daniel' and - name.length instead of '6'

var studentsPercentage=Math.round( (numberOfStudents/total)*100);
var mentorsPercentage=Math.round( (numberOfMentors/total)*100);
console.log(`Percentage students: ${studentsPercentage} %
\n Percentage mentors: ${mentorsPercentage} % `);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I liked that you used newline \n

//missing let & extra +

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!

// Add comments to explain what this function does. You're meant to use Google!
function getRandomNumber() {
return Math.random() * 10;
return Math.random() * 10; //The Math. random() function returns a floating-point, pseudo-random number in the range 0 to less than 1 (inclusive of 0, but not 1) with approximately uniform distribution over that range
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 is a great copy/paste from MDN Web Docs :) what's a floating-point, pseudo-random number?

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.

you are right , as it says we meant to google it , I just copy paste what I found and have no idea what that means :)) I eaven searched the meaning of it now and it got harder to understand ,I believe that Math.random() will return a number between 0 and 1 , I think it could include 0 but not the 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.

Nice! Any idea what kind of number? Positive? Negative? Decimal? Something else?

// Add comments to explain what this function does. You're meant to use Google!
function combine2Words(word1, word2) {
return word1.concat(word2);
return word1.concat(word2); //The concat() method is used to merge two or more arrays. This method does not change the existing arrays, but instead returns a new array.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Are you sure this function is dealing with arrays?

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.

Thanks for mentioning it leaded me to testing it , and it works for merging arrays, but t also works for merging strings ,there will be no space between merged strings though.

// 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.concat(` ${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.

This isn't wrong, but I'm curious why you chose to use a mixture of .concat() and then also string templating?

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.

good point, to be honest I have no idea either . I could have done it by adding .concat() twice as well.

Comment thread mandatory/4-tax.js

function calculateSalesTax() {}
function calculateSalesTax(price) {
return price+(price*20)/100
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 20. 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 = 20;

function calculateSalesTax(price) {
    let tax = price * TAX_RATE / 100;
    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.

yes you are totally right and your suggested solution is far better , I will keep it in mind and use this from now on.Thanks Jon.

Comment thread extra/1-currency-conversion.js Outdated
Co-authored-by: Jon Bevan <jon@jdbevan.com>
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.

5 participants