File tree Expand file tree Collapse file tree 4 files changed +7
-7
lines changed
1-js/04-object-basics/01-object/3-is-empty Expand file tree Collapse file tree 4 files changed +7
-7
lines changed Original file line number Diff line number Diff line change 11function isEmpty ( obj ) {
22 for ( let key in obj ) {
3- // if the loop has started, there is a property
3+ // если тело цикла начнет выполняться - значит в объекте есть свойства
44 return false ;
55 }
66 return true ;
Original file line number Diff line number Diff line change 11describe ( "isEmpty" , function ( ) {
2- it ( "returns true for an empty object " , function ( ) {
2+ it ( "возвращает true для пустого объекта " , function ( ) {
33 assert . isTrue ( isEmpty ( { } ) ) ;
44 } ) ;
55
6- it ( "returns false if a property exists " , function ( ) {
6+ it ( "возвращает false, если свойство существует " , function ( ) {
77 assert . isFalse ( isEmpty ( {
88 anything : false
99 } ) ) ;
Original file line number Diff line number Diff line change 1- Just loop over the object and ` return false` immediately if there's at least one property .
1+ Просто в цикле перебираем свойства объекта и возвращаем false как только встречаем свойство .
Original file line number Diff line number Diff line change @@ -2,11 +2,11 @@ importance: 5
22
33---
44
5- # Check for emptiness
5+ # Проверка на пустоту
66
7- Write the function ` isEmpty(obj) ` which returns ` true ` if the object has no properties, ` false ` otherwise .
7+ Напишите функцию ` isEmpty(obj) ` , которая возвращает ` true ` если у объекта нет свойств, иначе ` false ` .
88
9- Should work like that :
9+ Должно работать так :
1010
1111``` js
1212let schedule = {};
You can’t perform that action at this time.
0 commit comments