Skip to content

Commit 1c211c9

Browse files
committed
Added explanation for Iteration ironhack-labs#2 and Iteration # 3
1 parent b1db7f8 commit 1c211c9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/functions-and-arrays.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ function findLongestWord(array) {
2828

2929
console.log(findLongestWord(words));
3030

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+
3144

3245

3346

@@ -45,6 +58,10 @@ function sumNumbers(arrayNumbers) {
4558

4659
console.log(sumNumbers(numbers));
4760

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+
4865

4966
// Iteration #3.1 Bonus:
5067
function sum(array) {

0 commit comments

Comments
 (0)