File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,19 @@ function findLongestWord(array) {
28
28
29
29
console . log ( findLongestWord ( words ) ) ;
30
30
31
+ // 1. Inside the function declare and initialize variable word = ''.
32
+ // 2. Firstly, condition that checks that an array has values.
33
+ // 3. For loop iterates through the array, and if the length of the variable word less
34
+ // then the length of the word inside the array (recieve it via array[i].length), variable word get assigned the word from the array (array[i]).
35
+ /* 1st iteration i = 0; if (0 < 'mystery'.length)? => if (0 < 6)? word = 6;
36
+ 2st iteration i = 1; if (6 < 'brother'.length)? => if (6 < 6)? word = 6;
37
+ 3st iteration i = 2; if (6 < 'aviator'.length)? => if (6 < 6)? word = 6;
38
+ 4st iteration i = 3; if (6 < 'crocodile'.length)? => if (6 < 8)? word = 8;
39
+ 5st iteration i = 4; if (8 < 'pearl'.length)? => if (8 < 4)? word = 8;
40
+ 6st iteration i = 5; if (8 < 'orchard'.length)? => if (8 < 6)? word = 8;
41
+ 7st iteration i = 6; if (8 < 'crackpot'.length)? => if (8 < 7)? word = 8;
42
+ */
43
+
31
44
32
45
33
46
@@ -45,6 +58,10 @@ function sumNumbers(arrayNumbers) {
45
58
46
59
console . log ( sumNumbers ( numbers ) ) ;
47
60
61
+ // 1. Inside the function declare a variable sum and its value is 0.
62
+ // 2. For loop iterates through arrayNumbers, and each iteration sum adds number from the array (due to array[i]).
63
+ // 3. Return sum and check the function.
64
+
48
65
49
66
// Iteration #3.1 Bonus:
50
67
function sum ( array ) {
You can’t perform that action at this time.
0 commit comments