Coder Social home page Coder Social logo

hyf-javascript1's People

Contributors

rimsebai avatar

Watchers

 avatar

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

  1. Correct.

  2. 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 constant 1 as you have done now.

    Mind the spelling errors:

    • turtel -> turtle
    • valeu -> value

More JavaScript

  1. 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 be sum. Avoid meaningless or ambiguous names. Try and find names that accurately describe what the function (or variable or parameter) represents.

  2. 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, your colorCar() 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.

  3. 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.

  4. 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

  5. Correct.

  6. 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?

  7. Correct.

  8. Correct.

  9. 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 variable isNew 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.

  10. The correct string was printed. Please check the solution I posted in slack for an alternative approach.

  11. I don't see a modified advertisement text being printed.

  12. Correct.

  13. There is a spelling error in the variable name teachera (why the last a?)

    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.

  14. Here you are using the variable teachers, but this variable is not declared (e.g. by using const or let). Maybe you intended to reuse the variable from step 13, but that is not happening because of the spelling error.

  15. What is your explanation of what is happening here? I explained it in class.

  16. Same question as 15.

  17. Correct.

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.