Giter Site home page Giter Site logo

howprogrammingworks / datatypes Goto Github PK

View Code? Open in Web Editor NEW
35.0 21.0 220.0 132 KB

Built-in data types

Home Page: https://youtube.com/TimurShemsedinov

License: MIT License

JavaScript 90.02% Python 9.98%
data data-type data-types number string object function js javascript symbol

datatypes's Introduction

datatypes's People

Contributors

anisaanya avatar dependabot[bot] avatar komarov-sergey avatar kulia26 avatar metammodern avatar moonkxn avatar timagixe avatar tshemsedinov avatar wirtaw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

datatypes's Issues

Min length in 3-by-reference.test

I have solution:

const inc = num => { ++num.n; };

and npm test print:

Test 3-by-reference
  Length: 19, lines: 1
  Error: Solution is too short

so need fix file: 3-by-reference.test, line: length: [19, 70],

npm test command broken

This "test": "eslint ./Exercises; hpw" doesn't work.
Running this command says:

[email protected] test
eslint ./Exercises; hpw
Oops! Something went wrong! :(

ESLint: 8.40.0

No files matching the pattern "./Exercises;" were found.
Please check for typing mistakes in the pattern.

Probably it should look like "eslint ./Exercises && hpw"
But in this case, I do not understand the presence of "ci": "eslint ./Exercises && hpw"
Can anyone explain the proper way to test my exercises?

https://github.com/HowProgrammingWorks/DataTypes/blob/2695aaceec7efaefd07538b6e4aec3764bef86ac/package.json#LL8C16-L8C16

Null type checks is not considered by the tests length

There is a problem with countTypesInArray function (4-count-types.js). The tests require a solution to be 200 signs max, but in this case, we kinda lose the check for nulls.

As you know null in JavaScript has a type of object. Thus, the implementation you require will count objects but not nulls. So, the function is not suitable for checking all the JS types.

I clearly understand that such a check can be done using a ternary operator but it's not convenient and intuitive enough.

The implementation below considers this JS's quirk:

const data = [
  false,
  'a',
  22,
  'hey',
  undefined,
  42,
  12,
  true,
  { a: 12 },
  { name: 'Jack' },
  'foo',
  'bar',
  true,
  null,
  undefined,
  Symbol('a'),
  null
];

const countTypesInArray = data => {
  const h = {};
  for (const item of data) {
    if (typeof item === 'object' && item === null) {
      h['null'] = 1;

      if (h['null'] > 0) {
        h['null']++;
      }
    } else if (typeof item in h) {
      h[typeof item]++;
    } else {
      h[typeof item] = 1;
    }
  }
  return h;
};

console.log(countTypesInArray(data));

So, maybe you should consider an option for making tests a little bit more loose for null checks.

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.