hyf-javascript1's People
hyf-javascript1's Issues
Feedback homework week 1
Hi Rim, here is my feedback on your JS1 week 3 homework.
There are some hints in your code that suggest to me that you still need to add some settings to your VSCode editor, specifically having to do with code formatting. Please check the VSCode Tips again and make sure the recommended settings are applied.
Step 4: Strings and Array challenges
-
Correct.
-
In line 14 you correctly remove the third element of the array (
'giraffe'
). However, you then access the first element of the array (using bracket notation[0]
). There is no need to access the first element like this; it serves no useful purpose.The same applies to line 17.
Once you have found the index of
'meerkat'
you can save it in a variable and pass that variable to the.splice()
method to delete the element at the index found, rather than explicitly specifying the index as the constant1
as you have done now.Mind the spelling errors:
- turtel -> turtle
- valeu -> value
More JavaScript
-
The function works correctly, but the function name you chose (
myFunction
) doesn't say anything about what the function actually does. A natural name for this function would in my view besum
. Avoid meaningless or ambiguous names. Try and find names that accurately describe what the function (or variable or parameter) represents. -
Excellent that you let your function return the constructed string and that you do the
console.log
when you call the function. In other words, yourcolorCar()
function is pure. This means you can call your function for other purposes than just logging something to the console. For this simple function that may seem trivial but it starts to pay off when your functions become more complex. -
Functionally correct, but this code fragment is in dire need of some proper formatting, see Code Formatting in the fundamentals repo. If you apply the VSCode settings that I mentioned at the beginning here than this is done automatically for you.
Note that object property names should also be in camelCase:
LastName
->lastName
. -
Functionally correct. But it is considered a bad practice to reassign parameters. You receive a number in the parameter
code
that represents a code for a vehicle. But then you reassign it to a vehicle name. It is no longer a code. A better approach would be to introduce a new variable, for instance:let vehicleType = 'unknown vehicle type'; if (code === 1) { vehicleType = 'car'; } else if (code === 2){ vehicleType = 'motorbike'; }
Mind the spelling error:
bleu
->blue
-
Correct.
-
Functionally correct, but the code formatting could be improved. Mind the spelling error. See also step 4 for the point about reassigning parameters.
Why did you call the function in line 53 without doing anything with its return value?
-
Correct.
-
Correct.
-
You have a spelling error in your function name. You may have done that on purpose (if so, a comment explaining that you did so would have been helpful), or by accident. In any case, because of the spelling you have escaped the potential problem of having defined two functions with the same name in the same scope. If you do that, then the last defined function is the one that overrides all previous functions with the same name. In that case, your first calls to
vehicle()
in lines 53 and 54 would have called the function from step 9.Your function prints
'a green 1 bike'
rather than'a green new bike'
and the variableisNew
is assigned but not used.Why did you call the function in line 71 without doing anything with its return value?
Mind the spelling error.
-
The correct string was printed. Please check the solution I posted in slack for an alternative approach.
-
I don't see a modified advertisement text being printed.
-
Correct.
-
There is a spelling error in the variable name
teachera
(why the lasta
?)Do not use numbers as property names. Property names should be descriptive (for instance, a camelCase word).
Check the solution I posted in slack for an example.
-
Here you are using the variable
teachers
, but this variable is not declared (e.g. by usingconst
orlet
). Maybe you intended to reuse the variable from step 13, but that is not happening because of the spelling error. -
What is your explanation of what is happening here? I explained it in class.
-
Same question as 15.
-
Correct.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.