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

NorthWest Class 4 - Anza Azam - JavaScript - Week 1 - #104

Closed
Anza-Azam wants to merge 7 commits into
CodeYourFuture:masterfrom
Anza-Azam:master
Closed

NorthWest Class 4 - Anza Azam - JavaScript - Week 1#104
Anza-Azam wants to merge 7 commits into
CodeYourFuture:masterfrom
Anza-Azam:master

Conversation

@Anza-Azam

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?

@Anza-Azam

Copy link
Copy Markdown
Author

Your Details
Your Name: Anza Azam
Your City: NorthWest4
Your Slack Name: Anza-Azam
Homework Details
Module: Javascript Core 1 Module
Week: 1
Notes
What did you find easy?
functions
What did you find hard?
logic
What do you still not understand?
let and var
Any other notes? Thanks to all polite and patient volunteers

return "word".length();

var noSpaceString = word.trim();
return noSpaceString.length;

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 like the extra work you've done on this - word.length would have been enough to pass the test, but adding trim is a good idea. When you come to writing tests yourself, think about how you could write a test that would cover this extra functionality.

//This getRandomNumber() gives a random number between 0 and 10
function getRandomNumber() {
return Math.random() * 10;
return Math.random() * 10; //Math.random will return a number between 0 and 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.

Is Math.random inclusive of 1? And consequently is your method inclusive of 10? Check the definition here. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random

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.

learned now that this will not be inclusive of 1 or 10 so we have to add 1 to make these numbers inclusive, thanks really helped me.


var firstWords = combine2Words(firstWord, " ");
var secondWords = combine2Words(secondWord, " ");
return firstWords + secondWords + 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 works, but you could do it in one line - .concat can take any number of parameters.

Comment thread mandatory/4-tax.js
function calculateSalesTax(price) {
var newPrice = price + (20 / 100) * price;
return newPrice;
}

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 works fine. One change you could make is to declare 20, or 20/100 as a variable called taxRate or something similar, which would make it easier to understand what the code is doing. However, your method has the advantage of being more concise, so it's a matter of taste really, both are correct.

function convertToBRL(price) {
var newPrice = (price * 99) / 100;
var convertedBRL = (newPrice * 5.7).toFixed(2);
return parseFloat(convertedBRL);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe assign 5.7 to a variable called something like exchangeRate, just to make the code more understandable

Comment thread extra/2-piping.js
let goodCode =
let goodCode = add(startingValue, 10);
goodCode = multiply(goodCode, startingValue);
goodCode = format(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.

This is much better. I think it could be even easier to understand if you declare a new variable for each line, describing what had been done, i.e. valueAfterAddition. But this is just a personal preference, your way is fine

Comment thread extra/3-magic-8-ball.js
//Write your code in here

console.log("The ball has shaken!");
return answers[Math.floor(Math.random() * 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.

You could use answers.length here instead of 20, then you won't need to update the number if you add or remove anything from the array

Comment thread extra/3-magic-8-ball.js
status = "negative";
} else if (index >= 15 && index < 20) {
status = "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.

Do you need 2 parts to your if statements in lines 144, 146? Have you already established one of them? Do you need the check on line 148 at all?

@github-actions

github-actions Bot commented Aug 5, 2021

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 5, 2021
@github-actions github-actions Bot closed this Aug 5, 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.

2 participants