Skip to content

Commit d7aa946

Browse files
committed
Added changes on Iteration ironhack-labs#2
1 parent ad4104e commit d7aa946

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/functions-and-arrays.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,23 @@ maxOfTwoNumbers(4,4)
1111
// Iteration #2: Find longest word
1212
/* const words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpot'];
1313
14-
function findLongestWord(arr= ironhack){
14+
function findLongestWord(arr){
1515
let wordLength = '';
16+
if(arr.length == ''){
17+
return null
18+
}
1619
for (let i=0;i<arr.length;i++){
1720
if(arr[i].length > wordLength.length){
18-
19-
return wordLength += arr[i];
21+
wordLength = arr[i]
2022
}
2123
}
22-
return wordLength = null;
24+
return wordLength
2325
}
24-
findLongestWord(words)
25-
*/
26+
findLongestWord(words) */
27+
2628
// Iteration #3: Calculate the sum
2729

28-
const numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10];
30+
/* const numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10];
2931
function sumNumbers(arr){
3032
let sum = 0;
3133
if (arr.length == ''){
@@ -38,7 +40,7 @@ return sum
3840
}
3941
sumNumbers(numbers)
4042
41-
43+
*/
4244
// Iteration #4: Calculate the average
4345
// Level 1: Array of numbers
4446
const numbersAvg = [2, 6, 9, 10, 7, 4, 1, 9];

0 commit comments

Comments
 (0)