Coder Social home page Coder Social logo

hyf-javascript1's People

Contributors

karamad10 avatar

hyf-javascript1's Issues

Feedback homework week 3

Hi Karam, here is my feedback on your JS1 week 3 homework.

Your code looks well formatted, with code blocks nicely separated with blank lines. There are a few missing semicolons, though.

Step 4: Strings and Array challenges

  1. Excellent that you used the .replace() method in combination with a regular expression. We won't cover regular expressions in the lectures as it is an advanced, vast topic but at least you got a taste of it here.

  2. In line 12, the first argument should just be a number. What you have used is an array (because of the square brackets) of exactly one element. That element is the number 1. The fact that is still produces the correct result is pure luck!

    Note: Avoid mixing up single and double quotes for delimiting strings. Choose one or the other and stick to that for all your code.

More JavaScript

  1. The name you chose for this function does not accurately describe what it does. The name sum would be a natural name for this function. Always try to find names for your functions and variable that best describe what they do or represent.

    There is an extra comma after c in line 24 that should not be there.

    You don't need the parentheses that you used in the return statement. This will do: return a + b + c;

  2. When we say that a function receives some value, in this case a color, we mean that the function takes that as a parameter. So the function definition could look like this:

    coloredCar(color) {
      //...
    }

    And you would use that color parameter to print the color inside the function. That also allows me to call your function with a different color, say green and still get correct output.

  3. As in the previous step, your function should take the object as a parameter and then print out its content, for example:

    function printObj(obj) {
      // ...
    }
    
    const myObj = {
      //...
    };
    
    printObj(myObj);

    In this way I can call your function with any object and get its content printed. As it stands now I always get your Nissan.

  4. I think you got the code values mixed up. According to the assignment the 1 stands for car and 2 stands for motorbike.

  5. Correct.

  6. Although your function looks correct, it is not executed. This is because you created a function with the same name in step 9, which overwrites the version of step 6. So, in line 60 you are actually calling the function of step 9, which produces the output a Blue Motorbike rather than a Blue Used car. You can avoid this issue by renaming the function of step 9 to, say, vehicle2. Or you can put each exercise in a block scope as I have done in my solution of the homework.

  7. You created an array of objects, which if fine too, but for the exercises here you could have just created an array of strings, like you did in your alternative vehicles0.

    Note that in English, to form a plural, you do not use an apostrophe between the word and the final s, for example: motorbikes etc.

  8. Correct.

  9. Your function should use the code parameter to determine the type of vehicle to print out. In your version you have assumed that it is always a bike.

  10. (+11) Your code assumes that the last vehicle in the list is always cars. But there is no car in your vehicle list array.

  11. I don't see a new advertisement output with the boat added.

  12. Correct,

  13. Okay.

  14. Fine. But you could have use console.log to check the result.

  15. You could add a comment in which you describe what is actually happening.

  16. Same as above.

  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.