Giter Site home page Giter Site logo

hyf-javascript2's Introduction

hyf-javascript2

HYF Javascript Module 2

hyf-javascript2's People

Contributors

jamsrahimi avatar

Watchers

 avatar

hyf-javascript2's Issues

Comment

Yeah! It looks very clear and understandable. And I can easily understand that you are able to find more than 1 solution for an issue. This is really good to improve yourself. The last thing which I can tell you that I learned lots of thing which I could not get during the class. Thanks a lot. ๐Ÿ‘

Feedback homework JS2 Week 3

Hi Jams, here is my feedback on your homework.

Step 4.1

You've gone overboard a bit with this. I would have preferred a simple:

function foo(func) {
  func();
}

That is what the assignment asked for and that is what should be delivered; no more no less. Remember, your next reviewer may be your potential employer.

Of course, you can experiment as much as you like but don't send it in as the answer to the assignment.

Step 4.2

Your code works OK but again, I'm not interested to know whether the number is a prime or divisible by 2. The assignment doesn't ask for that. Similarly, I don't need reconfirmation that 15 is divisible by both 3 and 5. The preceding console.log statements already tell me that.

Step 4.3

OK

Step 4.4

OK

Step 4.5

OK

Step 4.6

No need to review my own version. Your version doesn't print the actual numbers, just the embedded arrays.

Step 4.7

I didn't see you conclusion for the second case with the object.

Step 5

OK

Bonus

Your code works OK, but:

  • You should use camelCase for your variable and function names, e.g. findDuplicateInArray.
  • We prefer one variable per declaration (it's a bit of old-style to do it in single declaration).
  • Declare the variable at the point of need.
  • arra1 is rather a cryptic name
  • Use 'constorlet` in place of var

You are exploiting the fact that object keys are unique. You can do the same and cleaner with the newer ES6 Set(). But if I refactor your code based on the bullets above it would become:

function findDuplicateInArray(array) {
    const obj = {};
    for (let i = 0; i < array.length; i++) {
        obj[array[i]] = 0;
    }
    const result = [];
    for (const key in obj) {
        result.push(key);
    }
    return result;
}
const arr = ['a', 'b', 'c', 'd', 'a', 'e', 'f', 'c'];
console.log(findDuplicateInArray(arr));

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.