Homework JavaScript 1
meazer / hyf-javascript1 Goto Github PK
View Code? Open in Web Editor NEWHomework JavaScript 1
Homework JavaScript 1
Hi Meazer, here is my feedback on your homework for week 3.
Another excellent piece of work!
Correct!
Correct!
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.
Correct! Nice that you used a switch
statement here.
Correct!
Correct!
Correct!
This looks very much like a math relation:
iif ((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 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.
Correct! But the example in the assignment has no comma before the word 'and'. See my message in slack for alternative implementations.
Correct
Correct! I like the way you used a for
loop to avoid having to use explicit numeric array indices.
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;
}
Correct!
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 2.
You've done a great job here. Your code works correctly, is nicely formatted and your choice of variable names is excellent.
A couple of minor points.
1. This file should actually be named strings.js
.
2. 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).
3. This file is missing a 'use strict'
line.
4. It is best to always use strict equality: use ===
instead of ==
.
5. This file is missing a 'use strict'
line.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.