diff --git a/1-exercises/B-while-loop/exercise.js b/1-exercises/B-while-loop/exercise.js index b459888f..d77744b8 100644 --- a/1-exercises/B-while-loop/exercise.js +++ b/1-exercises/B-while-loop/exercise.js @@ -6,7 +6,20 @@ */ function evenNumbers(n) { - // TODO + let i = 0; + let length=0; + let newArr=[]; + +while (length 50) return(i); + }while(i<=50); } /* ======= TESTS - DO NOT MODIFY ===== */ diff --git a/2-mandatory/3-financial-times.js b/2-mandatory/3-financial-times.js index 2ce6fb73..f26821a8 100644 --- a/2-mandatory/3-financial-times.js +++ b/2-mandatory/3-financial-times.js @@ -6,24 +6,65 @@ */ function potentialHeadlines(allArticleTitles) { // TODO + let checkedArticleTitles=[]; + for (let i = 0; i < allArticleTitles.length; i++) { + if (allArticleTitles[i].length<=65) { + checkedArticleTitles.push(allArticleTitles[i]); + } + } + return checkedArticleTitles; } - /* The editor of the FT likes short headlines with only a few words! Implement the function below, which returns the title with the fewest words. (you can assume words will always be seperated by a space) + let wordNums = [] + for (let i = 0; i < allArticleTitles.length; i++) { + wordNums.push(allArticleTitles[i].split(' ').length) + } + return allArticleTitles[wordNums.indexOf(Math.min(...wordNums))] + + */ function titleWithFewestWords(allArticleTitles) { // TODO + let allArticleTitleswithspacecount=[]; + let minIndex; + /*for (i=0;i