- Упражнения: Exercises.ru.md
- Примеры: JavaScript
howprogrammingworks / datatypes Goto Github PK
View Code? Open in Web Editor NEWBuilt-in data types
Home Page: https://youtube.com/TimurShemsedinov
License: MIT License
Built-in data types
Home Page: https://youtube.com/TimurShemsedinov
License: MIT License
Examples for: =, +=, -=, *=, /=, %=, **=, <<=, >>=, >>>=, &=, ^=, \|=
See MDN
See MDN
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],
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?
Examples for: &, |, ^, ~, <<, >>, >>>
See MDN
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 null
s.
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.
Examples for: +, -, *, /, %, ++, --, **
See MDN
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.