GithubHelp home page GithubHelp logo

hyf-javascript1's People

Contributors

allouhm avatar

Watchers

 avatar

hyf-javascript1's Issues

Feedback homework week 3

Hi Mahmoud, here is my feedback on your homework for week 3.

1-more

Correct!

2-more

Correct! Some minor issues:

  • The blank line (line 4) is meaningless. Best to remove it.
  • The string " a " should not start with a space.

3-more

Correct!

4-more

It seems you have overlooked this in the assignment:

Your function should return a string ...

By placing console.log statements inside the function body you are creating side effects. Here, these side effects are unneeded and undesired. You should just return a string and then use console.log when you call the function, for instance as you did in 2-more.

5-more

It is best to use a ternary statement to produce a value rather than to use it to cause side effects:

// your code
3 === 3 ? console.log("Yes") : console.log("No");

// preferred
console.log(3 === 3 ? "Yes" : "No");

6-more

Why don't you also make the distinction between new and used motorbikes?

As in 4-more, remove the console.log statements from the function body.

The most efficient way to deal with the age parameter id to handle it independently. That can simplify the conditions in your if statements:

const condition = age <= 1 ? 'new' : 'used';
//...
return "it is a " + color + " " + condition + " car";

7-more

The first vehicle in the list should have the index of 1 (see assignment 4). You have a one-off error here.

See the age comment above.

What if I call your function with -1 for code?

It is best to place the vehicle array inside the function body. This makes your function pure: the most desirable form for a function.

Remove the console.log statements from the function body.

Blank line 14 is meaningless.

8-more

The assignment asked for the array of vehicle names to be in singular form.

Your function should return a string. No console.log in the body (i.e. no side effects). From the assignment:

... returns a corresponding advertisement text string ...

It is best to place the adMessage variable inside the function body to make the function pure. Also, you can use const in place of let for addMessage.

9-more

See 8-more.

10-more

Correct!

11-more

To use a metaphor: x and y are like twin brothers, they look the same but are separate entities. However, z is just another name for x.

12-more

Correct!

13-more

Correct!

Feedback homework week 2

Hi Mahmoud, here is my feedback on your homework for week 2.

Overall you have done a pretty good job. There are some minor points for improvement.

1-strings.js

1. Be consistent in your use of quotes as string delimiter. Either choose single quotes or double quotes and then stick to that for all of your code (I prefer single quotes myself).

2-arrays.js

2. When you look for the position of an element in array you must take into account the possibility that you won't find it. Code like this will deal with that:

const index = favoriteAnimals.indexOf('meerkat');
console.log('the item you are looking for is at index :' + index);
if (index !== -1) {
  favoriteAnimals.splice(1, 1);
}

3-months.js

3. For better readability it would be nice to separate blocks of related code which a blank line, just as you would separate paragraphs in a piece of text with a blank line:

const months = [
  // ...
];

let daysTotal = 0;

for (let i = 0; i < months.length; i++) {
  //...
}

console.log('The total of days in this year is : ' + daysTotal, 'days.');

if (daysTotal <= 365) {
  //...
}
else {
  //...
}

Notice also that I have moved the definition of the variable daysTotal just before where it is first needed. This is a best practice: keep related code together.

4. There is a typo in a string constant: untill -> until. The spelling checker flags those errors with a green wavy underline.

4-maartje.js

5. There are a number of variables that you can declare with const rather than let. They are flagged by ESLint with green wavy underlines in VSCode. The const keyword is preferred over let if you do not intend to reassign a variable later.

6. If you want to report the paid hours (the assignment doesn't ask for it), you might want to do that in the HH:MM format. This output seems a bit awkward:

Only the paid hours =  18.666666666666668 hour

7. It is customary to place the โ‚ฌ-sign in front of the Euro money amount and print it with two decimals (accurate up to a Euro cent).

8. There is a typo in Maartje's name: Maatrje

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.