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

NorthWest_4 - Dharma_Guadeloupe - JavaScript_Core_1_Coursework - Week_1#111

Closed
dharmaguadeloupe wants to merge 29 commits intoCodeYourFuture:masterfrom
dharmaguadeloupe:master
Closed

NorthWest_4 - Dharma_Guadeloupe - JavaScript_Core_1_Coursework - Week_1#111
dharmaguadeloupe wants to merge 29 commits intoCodeYourFuture:masterfrom
dharmaguadeloupe:master

Conversation

@dharmaguadeloupe
Copy link
Copy Markdown

@dharmaguadeloupe dharmaguadeloupe commented Jun 22, 2021

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: Dharma Guadeloupe
  • Your City: NorthWest 4
  • Your Slack Name: Dharma

Homework Details

  • Module: JavaScript Module 1
  • Week: 1

Notes

  • What did you find easy? The exercises were great way to cement what I already knew

  • What did you find hard? Figuring out the ternary operator for the extra homework

  • What do you still not understand? Still a litle fuzzy on ternary's

  • Any other notes?


View rendered README.md
View rendered exercises/G-numbers/README.md

Copy link
Copy Markdown

@anthonytranDev anthonytranDev left a comment

Choose a reason for hiding this comment

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

Nice work Dharma!

Some comments for you below

Comment thread .vscode/settings.json
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": true
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Instructions Followed Incomplete (optional)

Instructions have mentioned the following Set editor.formatOnSave and editor.formatOnPaste to true

This is optional as I usually turn the latter settings off

@@ -1,2 +1,9 @@
var numberOfStudents = 15;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Incorrect Amount (Optional)

Isn't the correct amount of students and mentors, in your NW4 group - though will let you off. Most importantly, the core implementation is correct

function multiply() {
function multiply(num1, num2) {
// Calculate the result of the function and return it
return num1 / num2;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Incorrect operator

Needs a multiplication operator - i.e. not a division operator

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.

oops, honest mistake. That's what I get for not reading it properly. Fixed Now. Thanks

Comment thread extra/2-piping.js

/* BETTER PRACTICE */

let goodCode =
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ignore this exercise - there is little guidance here and both are bad practice, as you aren't making the code more readable or succinct

Answer below

// don't use somewhat useless functions, when operators do a better job (and are more readable)
const startingValue = 2
const bestCode = `${(10 + startingValue) * 2}`

Comment thread extra/3-magic-8-ball.js
Outlook not so good.
Very doubtful.
*/
**/
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Smart 🧠

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 less work 👍

Comment thread extra/3-magic-8-ball.js
Comment on lines +76 to +77
return answerIteration < 5 ? "very positive" : answerIteration >=5 && answerIteration < 10 ? "positive"
: answerIteration >=10 && answerIteration < 15 ? "negative" : "very negative";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Style

Please Never use nested ternary statements, ever

For the following multiplicity logic - not a real term, just a way I describe it.
Only use ternary for single branched out logic

For the code here, stick to using the following:

Increase in (reading) complexity the way down

  1. (A bunch of) if statements
  2. Then, switch statements (or objects - key value pairs, if you know how to use them)
  3. Lastly, if...else statements

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.

This was setting myself the challenge of seeing if I could convert it and understand nested ternary statements. Below is the code I used to work it out using If /else logic

Comment thread extra/3-magic-8-ball.js
Comment on lines +79 to +88
/**if(answerIteration < 5) {
return "very positive";
} else if(answerIteration >= 5 && answerIteration < 10) {
return "positive";
} else if(answerIteration >=10 && answerIteration < 15) {
return "negative"
} else {
return "very negative";
}**/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reducing complexity

  • This is actually more readable, you can try use a bunch of if statements
  • Oh avoid multiple return for if or if...else statements, try to assign the values, so that code flow can be read more linearly - it's more a special JavaScript style

Hint:

let message;

if(answerIteration < 5 ) {
  message = "very positive";
} 

if(answerIteration >= 5 && answerIteration < 10 ) {
  message = "positive";
} 
// etc ...

return message;

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.

That's something I've learned since, I was writing a lot of extra code that isn't actually needed. It's great to come back to this so many weeks later and see the difference between this, and how I write code now.

Comment thread extra/3-magic-8-ball.js
}

let seenPositivities = new Set(Array.from(answers.values()).map(checkAnswer));
let seenPositivities = new Set(Array.from(seenAnswers.values()).map(checkAnswer));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Arghhh...

Not your code, but I hate it. No one uses new Set in the industry, this isn't super easy to read either

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.

That worried for a minute as I was certain I hadn't written this

// 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.

Style

Remove unnecessary newline

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'm not sure what means

Comment thread mandatory/4-tax.js
const formattedCurrency = taxCalculation + product;
const salesTaxFormatted = formattedCurrency.toFixed(2);
return `£${salesTaxFormatted}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Style

Same here with removing the newline

@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 17, 2021
@github-actions github-actions bot closed this Aug 17, 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