@@ -6,13 +6,15 @@ function testValue (value) {
66 if ( typeof value == 'function' ) {
77 return false ;
88 } ;
9- if ( typeof value == 'string' && value . length != 10 ) {
10- return `Длина вашей строки: ${ value . length } .` ;
9+ if ( typeof value === 'string' ) {
10+ if ( value . length != 10 ) {
11+ return `Длина вашей строки: ${ value . length } .` ;
12+ } ;
13+ if ( value . length == 10 ) {
14+ return 'you win' ;
15+ } ;
1116 } ;
12- if ( typeof value == 'string' && value . length == 10 ) {
13- return 'you win' ;
14- }
15- }
17+ } ;
1618let typeofNumber = 10 ;
1719let typeofObject = {
1820 name : 'Natalia'
@@ -33,31 +35,33 @@ console.log(testValue(typeofString10));//'you win'
3335
3436//Task2
3537function numbersBetween ( a , b ) {
36- if ( typeof a == 'number' && typeof b == 'number' ) {
37- for ( let i = a ; i <= b ; i ++ ) {
38- console . log ( i ) ;
39- } ;
38+ let arr = [ ] ;
39+ if ( typeof a !== 'number' && typeof b !== 'number' ) {
40+ return 'Вы ввели не числа' ;
41+ }
42+ for ( let i = a ; i <= b ; i ++ ) {
43+ arr . push ( i ) ;
4044 } ;
45+ return arr ;
4146} ;
4247
43- numbersBetween ( 3 , 5 ) ;
48+ console . log ( ' numbersBetween' , numbersBetween ( 3 , 5 ) ) ;
4449
45- numbersBetween ( 10 , 12 ) ;
50+ console . log ( ' numbersBetween' , numbersBetween ( 10 , 12 ) ) ;
4651
4752
4853
4954//Task3
5055function FizzBuzz ( num ) {
51- if ( num % 3 == 0 && num % 5 == 0 ) {
52- console . log ( 'FizzBuzz' ) ;
53- } else if ( num % 3 == 0 ) {
54- console . log ( 'Fizz' ) ;
55- } else if ( num % 5 == 0 ) {
56- console . log ( 'Buzz' ) ;
57- } else {
58- console . log ( num ) ;
59- } ;
60- }
56+ let str = '' ;
57+ if ( num % 3 === 0 ) {
58+ str = str + 'Fizz' ;
59+ } ;
60+ if ( num % 5 === 0 ) {
61+ str = str + 'Buzz' ;
62+ } ;
63+ return str . length === 0 ? num : str ;
64+ } ;
6165
6266function fizzBuzz100 ( number ) {
6367 for ( let i = number ; i <= 100 ; i ++ ) {
@@ -138,9 +142,10 @@ let category = webStore.category;
138142
139143function dataProcessing ( data ) {
140144 for ( let key in category ) {
145+ let categoryItems = category [ key ] ;
141146 console . log ( `Категория: ${ key } ` ) ;
142- for ( let i = 0 ; i < category [ key ] . length ; i ++ ) {
143- console . log ( ` Содержимое категории: ${ category [ key ] [ i ] } ` ) ;
147+ for ( let i = 0 ; i < categoryItems . length ; i ++ ) {
148+ console . log ( ` Содержимое категории: ${ categoryItems [ i ] } ` ) ;
144149 } ;
145150 } ;
146151} ;
0 commit comments