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

London 9 - Karleen Richards - Javascript - Core 1 - Coursework - Week 1 - #451

Open
karleenmsrichards wants to merge 7 commits into
CodeYourFuture:masterfrom
karleenmsrichards:master
Open

London 9 - Karleen Richards - Javascript - Core 1 - Coursework - Week 1#451
karleenmsrichards wants to merge 7 commits into
CodeYourFuture:masterfrom
karleenmsrichards:master

Conversation

@karleenmsrichards

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?

Comment thread extra/2-piping.js Outdated
function add() {

function add(a,b) {
return +(a + b).toFixed(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.

Great job!
I think the task was to give the total No 2 decimals .toFixed(2)

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.

Hi hi, thank you. But my interpretation of this test: "test("add function - case 2 works", () => {
expect(add(2.4, 5)).toEqual(7.4);
})" is that I should ensure that there is one decimal place and not 2 for example if I use .toFixed(2) as you suggested, my answer may end up like 7.40 instead of 7.4 as an example left in the test.

I could be wrong but that is how I looked at it.

Also if I did not put .toFixed(1) I would get the recommended 7.4 and 10.1 but again I am not too sure what they expected hence I added .toFixed(1)

@PeteLindsell PeteLindsell 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.

Well done on getting through the mandatory tasks and onto some of the extra tasks!

I think you may have missed the exercises section.

Comment on lines 13 to 17
function getTotal(a, b) {
total = a ++ b;

return "The total is total";
a = 23;
b = 5;
return "The total is " + (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.

This wants to be something like the following:

function getTotal(a, b) {
  const total = a + b;
  return "The total is total " + total;
}

By reassigning a and b in the function means you are throwing away the values being passed in

Comment on lines +7 to +11
function introduceMe(name, age) {
name = "Sonjide";
age = 27;
return "Hello, my name is " + name + " and I am " + 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.

the return string is correct but you dont want to reassign name and age to static values otherwise this function cant be used fore anyone that is not called Sonjide and happens to be 27 years old

Comment thread extra/2-piping.js
Comment on lines +49 to +51
let first = startingValue + 10;
let second = first * 2;
let goodCode = format(second);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Well done on getting onto this!

Comment thread mandatory/4-tax.js
Comment on lines +25 to +27
function addTaxAndFormatCurrency(b) {
return "£" + ((20 / 100 * b) + b).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.

Good use of .toFixed()

(20 / 100 * b) + b can be written as b * 1.2 but your version is better when the percentage is being passed in as a value eg 20

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.

Hi Pete, I'm not sure if I understand what you mean. Can you please explain this more. Should I change it to b * 1.2?

@karleenmsrichards

Copy link
Copy Markdown
Author

Thank you Pete. I have made the necessary adjustments apart from the one that I need clarification on. Also I did the exercises since September they are probably in another repo. I will sort it out and get back to you. Thanks much.

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