Git Product home page Git Product logo

hyf-javascript1's People

Contributors

zmagzoub avatar

hyf-javascript1's Issues

Feedback homework week 3

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

Overall, you've done pretty well. Try and make your functions pure and without side effects as much as you can.

more01.js

Excellent!

more02.js

  • ESLint warns that myCar could be declared with const. The latter is preferred over let if the variable is not reassigned. In general, const should be your first choice as it gives the best protection against inadvertent modification. Only where you find that you need to change the variable somewhere else you should revert to let.

  • Be consistent in your use of upper and lower case.

    a Black car -> a black car, or, A black car.
    

more03.js

  • Excellent use of for...in. You can also use Object.keys() and use a regular for loop or a for...of loop. Note that property can be a const as ESLint indicates. In general, you should follow up on all issues identified by ESLint. That's the whole point of ESLint: to give you warnings and errors where your code can (and should) be improved.

more04.js

  • You seem to have missed this instruction from the assignment:

    Your function should return a string, ...

    In general, you should strive to make your functions pure and without any side effects. This makes your functions reusable and easy to test. In this case, don't use console.log in your function. Instead, use console.log to print the return value of your function, like you did for instance in more01 and more02.

  • I had expected 'a yellow unknown vehicle' for the third call, but I guess the assignment is not totally clear on that.

more05.js

Excellent!

more06.js

  • Don't use console.log inside your function. See the comment for more04.js.
  • Why do you only report the condition of the vehicle if it is a car?
  • ESLint warns that there is a semicolon missing in line 21.

more07.js

  • This looks very much like a math relation:

    if ((0 < code) && (code <= vehicles.length)) {
    //  0 < code <= vehicles.length

    Most developers would write this as:

    if (code > 0 && code <= vehicles.length) {

    You don't need the extra parentheses because the logical operator && is of lower precedence than the comparison operators. However, they don't do harm either.

  • In this exercise, I would move the vehicles constant inside the function body and move the console.log out of it. This again makes the function pure and without side effects.

more08.js, more09.js

  • Whenever you need to work on an array you probably need some form of for loop (or, as you will learn in JS2 week 2, array methods). With an array you should not make assumptions about its length, and you should not access array elements with hard-coded numeric array indices. Your code should work with an array of zero or more elements. I think Tamim did this exercise in class, so I won't cover it further here.

more10.js

  • Use const where ESLint gives you warnings about using let.
  • Remove the blank line in line 7. It serves no purpose. Use blank lines to separate blocks of related code, like you would use a blank line to separate paragraphs in a piece of written text. Remove blank lines for which you have no clear explanation.
  • There is a missing semicolon in line 4.

more11.js

  • I see no comment with an explanation. I'll give you one, using 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.

more12.js

  • I think you got it.

more13.js

  • Missing 'use strict';
  • Your conclusion is correct.

Feedbbck homework week 2

Hi Zaed, here is my feedback on your homework.

Your code is correct, it produces the correct results. Nice work! Please pay attention to the following points.

1. Your code is in some places not indented in a standard way. That indicates to me that you didn't set the VSCode settings correctly. We did this in class last Sunday, but somehow you seem to have missed it. Please check again the VSCode Tips for these settings.

2. You are missing a semicolon in line 4 of 1-strings.js. ESLint issued a warning for this (did you see the green wavy underline?) There is also one missing in 2-arrays.js.

3. In line 15 of 2-arrays.js, where you are looking for the index of meerkat, it would be better to save that index into a variable. The reason for that is because you are trying delete meerkat from the array in line 16. You should not "hard code" the number 1, but instead use the value you found earlier. Then you can easily deal with the situation of the index of meerkat being changed, e.g. because something was inserted, or that meerkat was deleted by some other code. In the latter case the index would be -1, indicating that nothing was found.

Example:

const meerkatIndex = favoriteAnimals.indexOf('meerkat');
console.log('Item to be deleted is at index: ' + meerkatIndex);
if (meerkatIndex !== -1) {
  favoriteAnimals.splice(meerkatIndex, 1);
}
console.log(favoriteAnimals);

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.