Hi Meazer, here is my feedback on your homework for week 3.
Another excellent piece of work!
1-more.js
Correct!
2-more.js
Correct!
3-more.js
Correct! But note that the loop variable pro can be declared with const rather than let, as indicated by ESLint. You should use const wherever you can as it provides protection against inadvertent reassignment. Use let only when you intend to reassign the variable somewhere else in your code.
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.
4-more.js
Correct! Nice that you used a switch statement here.
You don't need parentheses around the condition as the logical operator && has lower precedence than the comparison operators, but if they make the code more clear for you, no problem to leave them in.
You could move the vehicles array inside the function body so that your function becomes pure.
8-more.js
Correct! But the example in the assignment has no comma before the word 'and'. See my message in slack for alternative implementations.
9-more.js
Correct
10-more.js
Correct! I like the way you used a for loop to avoid having to use explicit numeric array indices.
11-more.js
Correct!
You don't need an else if the preceding if block always returns:
function equal(arr1, arr2) {
if (arr1.length !== arr2.length) {
return false;
}
for (let i = 0; i < arr1.length; i++) {
if (arr1[i] !== arr2[i]) {
return false;
}
}
return true;
}
12-more.js
Correct!
13-more.js
Note that typeof is not a function; it is an operator. If it were a function you would have to use parentheses and supply it an argument. See MDN typeof.
Hi Meazer, here is my feedback on your homework for week 3.
Another excellent piece of work!
1-more.js
Correct!
2-more.js
Correct!
3-more.js
Correct! But note that the loop variable
pro
can be declared withconst
rather thanlet
, as indicated by ESLint. You should useconst
wherever you can as it provides protection against inadvertent reassignment. Uselet
only when you intend to reassign the variable somewhere else in your code.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.
4-more.js
Correct! Nice that you used a
switch
statement here.5-more.js
Correct!
6-more.js
Correct!
7-more.js
Correct!
This looks very much like a math relation:
Most developers would write this as:
You don't need parentheses around the condition as the logical operator
&&
has lower precedence than the comparison operators, but if they make the code more clear for you, no problem to leave them in.You could move the
vehicles
array inside the function body so that your function becomes pure.8-more.js
Correct! But the example in the assignment has no comma before the word 'and'. See my message in slack for alternative implementations.
9-more.js
Correct
10-more.js
Correct! I like the way you used a
for
loop to avoid having to use explicit numeric array indices.11-more.js
Correct!
You don't need an
else
if the precedingif
block always returns:12-more.js
Correct!
13-more.js
Note that
typeof
is not a function; it is an operator. If it were a function you would have to use parentheses and supply it an argument. See MDN typeof.