Git Product home page Git Product logo

hyf-javascript1's People

Contributors

damla78 avatar

Watchers

 avatar

hyf-javascript1's Issues

Feedback homework week 3

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

There are some hints in your code that suggest to me that perhaps 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. 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. My favourite (not ๐Ÿ˜‰) animal , the meerkat is supposed to come between blowfish and capricorn, not where it is now. The rest is correct.

More JavaScript

  1. Excellent that you chose the name sum for the function. That describes 100% what it does.

  2. You chose the name colorCarVar for the function parameter. Probably because the name colorCar was already taken by the function itself. However, the Var suffix does not add meaning to the name, it is just there to make the name unique. It is rather a mouth full (try to say it quickly a number of times in a row ๐Ÿ˜). I would go for the simpler name color.

    By the way, excellent that you made your function pure, rather then using console.log directly in the function body.

  3. Correct.

  4. Although your function looks correct, it is not executed. This is because you created a function with the same name in line 81, which overwrites the version of line 64. So the function call in line 69 actually calls the function of line 81.

    Apart from that, excellent again that your function is pure. We can use its return value to log to the console or do something completely else. The suffix Veh on typeVeh does not add any useful meaning. We can already guess it is about the vehicle type from the fact that the function is about vehicles. I would just go for the name type.

    What I said half jokingly in step 2 above, pronounceable names are always preferred over cryptic names. Especially helpful if you want to discuss your code with somebody else over the telephone!

    Excellent that you build up the string from the supplied parameters. Note that when you use the string concatenation operator += you should not use another + following it. And in the ternary operator you don't need the parentheses around the condition, although it is perfectly fine to do so if that makes it more clear to you:

    str += type === 1 ? ' car' : ' motorbike';
  5. Correct.

  6. Excellent. ageVehicle? -> age will do just fine.

  7. If you just need to create an array of known vehicles, a simple array literal is cleaner:

    const vehicles = ['car', 'motorbike', 'bike', 'caravan', 'boat', 'metro', 'train'];
  8. You got the fourth element instead of the third element. Remember that array indices start at zero.

  9. Here, you correctly changed the name of the function so that it does not conflict with an earlier version of that function. And you also correctly adjusted the index of the array to take into account that array indices start at zero.

  10. As we discussed briefly in class, you need to use the plural form for each vehicle to make it correct English. See my solution for an alternative approach for this function.

  11. Correct.

  12. This is not an empty object but an empty array.

  13. Again, this is not an object but an array.

  14. Actually for the languages, we meant computer languages. If somebody taught you Chinese, you were in the wrong class!

  15. The explanation that you give in step 16 also holds true for this step.

  16. Your explanation is correct.

  17. Correct

You have some extra code at the end of your file that is a bit puzzling:

y = parseInt(x);
console.log( typeof y);

The variable y was declared at line 146, but reassigned here. Variable x refers to an array (defined in line 146). The parseInt() function expects a simple number as its argument. Anyway, this code does not seem to correspond to any assignment.

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.