London 10 | Shahid Amin | JavaScript-Core-1-Coursework-Week3#277
London 10 | Shahid Amin | JavaScript-Core-1-Coursework-Week3#277Schboostie wants to merge 14 commits intoCodeYourFuture:mainfrom
Conversation
Comment to show the stages of working - This needs to be put in a function
| let hello = sayHello(); | ||
| console.log(hello); | ||
|
|
||
| //There is no value passed to the function sayHello |
There was a problem hiding this comment.
Good, but not every function will have parameters. There's something missing inside the function sayHello for it not to be undefined. Can you spot what it is?
| let mentors; // Create an array with the names of the mentors: Daniel, Irina and Rares | ||
| let numbers = [1,2,3,4,5,6,7,8,9,10]; // add numbers from 1 to 10 into this array | ||
| let mentors = ["Daniel", "Irina", "Rares"]; // Create an array with the names of the mentors: Daniel, Irina and Rares | ||
|
|
|
|
||
| function last(arr) { | ||
| return; // complete this statement | ||
| return arr[arr.length - 1]; ; // complete this statement |
| AGES.forEach(k => { | ||
| WRITERS.forEach(i => { | ||
| console.log(i + " is " + k + " years old") | ||
| }) | ||
| }) |
There was a problem hiding this comment.
This doesn't look correct. Currently, it will say that every writer is 59,40,41,63 and 49 years old.
| // TODO | ||
| for (let dateOfBirth of BIRTHDAYS) { | ||
| let getMonth = dateOfBirth.split(' ')[0]; | ||
| if (getMonth === "July") { | ||
| return dateOfBirth; | ||
| } | ||
| } |
| function potentialHeadlines(allArticleTitles) { | ||
| // TODO | ||
| const shortArticleTitles = []; | ||
| for (let articleTitle of allArticleTitles) { |
There was a problem hiding this comment.
Good job overall code inside the function will work correct but it doesn't seem to output a value. You are definitely missing something here.
| */ | ||
| function titleWithFewestWords(allArticleTitles) { | ||
| // TODO | ||
| let fewestword = allArticleTitles[0].split(' ').length; |
| let numbers = [1, 2, 3]; // Don't change this array literal declaration | ||
|
|
||
| numbers[3] = numbers.push(4) | ||
| //The first value is 1??? |
There was a problem hiding this comment.
Good spot I'll forward that observation. But if it wasn't a 1 how would you change its value?
| let arrayOfLengths = allArticleTitles.map(w => w.length); | ||
| console.log(arrayOfLengths) | ||
| let sumOfLengths = 0; | ||
| for (let i = 0; i < arrayOfLengths.length; i++) { | ||
| sumOfLengths += arrayOfLengths[i]; | ||
| console.log(sumOfLengths) | ||
| } | ||
|
|
||
| let sumOfArrayLengths = arrayOfLengths.length | ||
| console.log(sumOfArrayLengths) | ||
|
|
||
| let result = sumOfLengths/sumOfArrayLengths; | ||
| console.log(result) |
| averageprice.push(Math.round(average * 100) / 100); | ||
|
|
||
| } | ||
| return averageprice; |
There was a problem hiding this comment.
Good effort. Please make sure you indent your code correctly.
Functions for the radio station and the books completed.
No description provided.