21 lines
310 B
Markdown
21 lines
310 B
Markdown
importance: 5
|
|
|
|
---
|
|
|
|
# Count properties
|
|
|
|
Write a function `count(obj)` that returns the number of properties in the object:
|
|
|
|
```js
|
|
let user = {
|
|
name: 'John',
|
|
age: 30
|
|
};
|
|
|
|
alert( count(user) ); // 2
|
|
```
|
|
|
|
Try to make the code as short as possible.
|
|
|
|
P.S. Ignore symbolic properties, count only "regular" ones.
|
|
|