Skip to content

Feedback homework week 3 #3

@remarcmij

Description

@remarcmij

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

I think you did pretty well. The advertisement assignment has been a challenge for all previous classes, so no worries there.

1-more.js

  • Remove the blank line in line 5. 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.

2-more.js

  • Remove blank line 5.
  • Be consistent in how you use quotes. Either all single quotes (my preference) or all double quotes. (This goes for all exercises, so I won't repeat it any more).

3-more.js

Excellent!

4-more.js

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

5-more.js

Excellent!

6-more.js

  • ESLint gives a warning that condition on line 6 could be a 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.

7-more.js

  • Excellent use of an array to avoid a chain of if...else statements for the typeOfWheels.

  • I would not include a space in the vehicle names. The space is needed for presentation purposes, it is not part of the data. Therefore, include the space at the point of presentation. (Same goes for "new" and "used".) This recommendation is an application of the principle of Separation of Concerns.

    const typeOfWheels = ["car", "motorbike", "caravan", "bike"]; // <== data
    result = "a " + color + condition + " " + typeOfWheels[type]; // <== presentation

8-more.js, 9-more.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.

10-more.js

  • When you run the code you will see that only the array element with the last index listed gets the language assigned to it:

    ourWonderfulTeachers[0, 1].languages = ["JavaScript"]; // <== only Rohan gets assigned this language

    Check MDN Comma Operator for an explanation.

11-more.js

  • 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.js

  • Yep

13-more.js

  • The typeof returns the type of a value as a string, e.g. 'number', 'string', 'object' etc. The typeof of the value returned by typeof is therefore a 'string'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions