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

London Class 7 - Yasemin Bayraktutan-JavaScript Core 1- Week 1 - #35

Closed
ybayraktutan wants to merge 3 commits into
CodeYourFuture:masterfrom
ybayraktutan:master
Closed

London Class 7 - Yasemin Bayraktutan-JavaScript Core 1- Week 1#35
ybayraktutan wants to merge 3 commits into
CodeYourFuture:masterfrom
ybayraktutan:master

Conversation

@ybayraktutan

Copy link
Copy Markdown

exercises and mandatory completed

Your Details

  • Your Name: Yasemin Bayraktutan
  • Your City: London
  • Your Slack Name: Yasemin

Homework Details

  • Module: JavaScript Core 1
  • Week: 1

return message;
}

console.log (createShoutyGreeting("Daniel"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi Yasemin, It would be better to use variable names as the function parameter in console.log
your code is nicely indented. well done

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.

Thank you very much. I have changed this.

// Write your function here
function createGreeting(firstName) {
var message = "Hello, my name is " + firstName;
return message;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For functions that are small and only do one operation (such as this one that does a string concatenation), you don't need to assign it to a variable first. You can just return the statement from the function. It's a bit cleaner and easier to read.

E.g.

function createGreeting(firstName) {
    return "Hello, my name is " + firstName;
}

// Declare your function here
function createLongGreeting (firstName, age) {
let message = "Hello, my name is " + firstName + " and I'm " + age + " years old";
return message;

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 would avoid assigning the variable here and just return the statement directly.

@@ -1,7 +1,7 @@
function halve(number) {
// complete the function here
return number/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.

It would be better if you added some spaces between the operator here, it makes it easier to read.

return number / 2

@@ -1,7 +1,7 @@
function triple(number) {
// complete function here
return number*3;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same here, add spacing around the maths operators.

function multiply() {
// Calculate the result of the function and return it
function multiply(a,b) {
return 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.

Same here, add spacing around the maths operators.

var mentor2 = "Irina";
var mentor3 = "Mimi";
var mentor4 = "Rob";
var mentor5 = "Yohannes";

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 this code from a different exercise? 🤔

total = a ++ b;

return "The total is total"
let total = 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.

You can directly return the statement here.

Comment thread mandatory/4-tax.js
let taxedPrice = price * 120 / 100;
return taxedPrice;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Based on the name of this function calculateSalesTax, I would expect that it would return the amount of sales tax for the item, not the cost of the item including sales tax. If I wanted the cost of the item with tax, i'd probably name it `calculatePriceWithTax'.

The names of the function should indicate what it does. You can use this as a clue to what you should write.

Comment thread mandatory/4-tax.js
@@ -17,7 +20,10 @@ function calculateSalesTax() {}
Remember that the prices must include the sales tax (hint: you already wrote a function for this!)
*/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note the hint here, it says you already created a function that calculates the sales tax.
So in the function addTaxAndFormatCurrency we want you to use the function calculateSalesTax to calculate what the new price should be.

Again, look at the name of the function, it gives you a clue to what the logic should be.

@louisechow

Copy link
Copy Markdown

You've done a great job Yasemin! 👍

You are very good at giving your variables a meaningful name and indent your functions well.

My top tips would be to make sure you are consistent with the way you write your functions (always add spacing around mathematical operators and return simple statements directly from functions). You've done this in some of the files but not others.

Also, pay attention to the names of functions. They will give you hints for what the function should do. Take a look at the comments I added to the tax.js exercise.

@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 May 13, 2021
@github-actions github-actions Bot closed this May 13, 2021
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